B bazp Member Licensed User Longtime User May 25, 2011 #1 Basic Array Tutorial Question I am having a hard time using arrays. I need to do such basic tasks as converting a text field 10 characters long to 10 one character array fields. I also want to lookup an array using a search word and getting back an index. I know you must have such a tutorial but I can't find it. I have been using substring functions but it is very ineficient. Last edited: May 26, 2011
Basic Array Tutorial Question I am having a hard time using arrays. I need to do such basic tasks as converting a text field 10 characters long to 10 one character array fields. I also want to lookup an array using a search word and getting back an index. I know you must have such a tutorial but I can't find it. I have been using substring functions but it is very ineficient.
Erel B4X founder Staff member Licensed User Longtime User May 25, 2011 #2 You will not get a faster solution than using substring. Substring should be very very fast for a 10 characters string. Can you post some code, demonstrating what takes too long? Upvote 0
You will not get a faster solution than using substring. Substring should be very very fast for a 10 characters string. Can you post some code, demonstrating what takes too long?
B bazp Member Licensed User Longtime User May 25, 2011 #3 Bad array samples It would be nice to have the correct array equivilents. These work but take took much code and are not efficient. Load 10 character field to ten 1 character array elements ------------------------------------------------------- dim x as int dim y as int For x= 0 To 9 y=x+1 let(x)=word1.SubString2(x,y) Next A silly example of an array look up and update (lookup "a" make it "?" ---------------------------------------------------------------- For x=0 To 48 if let(x)="a" Then let(r)="?" End If Next Upvote 0
Bad array samples It would be nice to have the correct array equivilents. These work but take took much code and are not efficient. Load 10 character field to ten 1 character array elements ------------------------------------------------------- dim x as int dim y as int For x= 0 To 9 y=x+1 let(x)=word1.SubString2(x,y) Next A silly example of an array look up and update (lookup "a" make it "?" ---------------------------------------------------------------- For x=0 To 48 if let(x)="a" Then let(r)="?" End If Next
K kickaha Well-Known Member Licensed User Longtime User May 25, 2011 #4 I need to do such basic tasks as converting a text field 10 characters long to 10 one character array fields. Click to expand... Can you use ToChars, or failing that use StringToBytes then CharsFromBytes? Have a look at this Library Last edited: May 25, 2011 Upvote 0
I need to do such basic tasks as converting a text field 10 characters long to 10 one character array fields. Click to expand... Can you use ToChars, or failing that use StringToBytes then CharsFromBytes? Have a look at this Library
NeoTechni Well-Known Member Licensed User Longtime User May 25, 2011 #5 And a big help, if you want an array that can change sizes, use the list variable type Upvote 0