how to let Trond code here to work in PB 5.50 :
http://purebasic.fr/english/viewtopic.php?f=13&t=25999
Thanks
			
			
									
									
						about PeekS
Re: about PeekS
[PB 5.50] Result
			
			
									
									Code: Select all
a$ = "the cat in the hat "
Length = Len(a$)
For t=1 To Length
  Letter.s = PeekS(Ascii(a$)+t-1, 1, #PB_UTF8)
  Word.s = Word + Letter
  If Letter = " "
    Debug Word + "."
   ; or some other process
    Word = ""
  EndIf
Nextthe .
cat .
in .
the .
hat .
➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti
Sorry for my bad english and the Dunning–Kruger effect
Re: about PeekS
Here is the version which should work in ascii and unicode mode:
Also Ascii() return a dynamic buffer which needs to be freed or you will experience a leak.
			
			
									
									
						Code: Select all
a$ = "the cat in the hat "
Length = Len(a$)
For t=1 To Length
  Letter.s = PeekS(@a$+(t-1)*SizeOf(Character), 1)
  Word.s = Word + Letter
  If Letter = " "
    Debug Word + "."
   ; or some other process
    Word = ""
  EndIf
NextRe: about PeekS
Code: Select all
a$ = "the cat in the hat "
Length = Len(a$)
For t=1 To Length
  Letter.s = PeekS(a$+(t-1) * SizeOf(Character), 1)
  Word.s = Word + Letter
  If Letter = " "
    Debug Word + "."
   ; or some other process
    Word = ""
  EndIf
Next - netmaestro
 - PureBasic Bullfrog

 - Posts: 8452
 - Joined: Wed Jul 06, 2005 5:42 am
 - Location: Fort Nelson, BC, Canada
 
Re: about PeekS
If one is being asked to take a string consisting of an expression in human language and break it down into its individual words, the first option from PureBasic that comes to mind is StringField(). Is there a reason to dismiss it and look elsewhere?
			
			
									
									BERESHEIT
						Re: about PeekS
Thanks for the solutions
it is may be not available in 2007 purebasic version
i just want the PeekS to work.
			
			
									
									
						no i know StringField() is a good and better choice https://www.purebasic.com/documentation ... field.htmlStringField(). Is there a reason to dismiss it and look elsewhere?
it is may be not available in 2007 purebasic version
i just want the PeekS to work.
Re: about PeekS
StringField()?applePi wrote:it is may be not available in 2007 purebasic version
StringField is available since 9. Oktober 2002, PB Version 3.40.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

						Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.




