View Full Version : string for text file to variable
felicecarrella
03-26-2007, 08:50 AM
Hi,
I'have some problem to load a string from file to variable or table.
Ex.
I' have this string in textfile:
X,Y,Z,2,5
H,J,K,6,3
.......
I' want load this in a some Variable or Table and add to listbox only the first letter.
If you have some code please send me.
Thanks
Protocol
03-26-2007, 01:33 PM
Hey there felice...
The easiest way would be to use the "textfile to table" function. So if your textfile has 4 lines of text...say:
www
xxx
yyy
zzz
Then using the textfile to table function (and calling the table MyTable) would create a table called MyTable which would look something like this to the computer:
{www,xxx,yyy,zzz}
You could then call upon any of that table's elements by requesting the info from a specific slot. In this case www=1, xxx=2, yyy=3 and zzz=4. You could convert a table's element into a variable (say..."MyVariable") using the following code:
MyVariable = MyTable[1]
This would mean that wherever you use the variable "MyVariable", it would have the value of "www" (or whatever is in position 1 in the table you created ealier). If you typed "MyVariable = MyTable[3]", then "MyVariable" would have the value of "yyy" (or whatever was in position 3 in the table you created), etc.
You can then use the String Left funtion to create a string from the Left-most character of the new String called "MyVariable" calling it...say..."MyString". Now if MyVariable had a value of "www", then MyString has a value of "w".
Now use the Add To Listbox function and insert MyString to the index of your choice (0 being the first index and -1 being the last).
These are listed in the help and tutorial section of AMS, but I know that it's sometimes easier to have someone walk you through it. Play around a bit with these directions and modify as you see fit. Have fun! Let me know if this isn't what you were looking for...
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.