| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| READTOARRAY COMMAND https://mail.black-squirrel.com/viewtopic.php?f=15&t=21596 |
Page 1 of 1 |
| Author: | Yop_Solo [ Sun Feb 22, 2009 10:10 pm ] |
| Post subject: | READTOARRAY COMMAND |
Could we ReadtoArray to bring back two categories of information in one reference.Txt EXAMPLE : babla 2 (FirstdataTXT SeconddataNumbers) and so on... FirstdataTXT SeconddataNumbers FirstdataTXT SeconddataNumbers FirstdataTXT SeconddataNumbers FirstdataTXT SeconddataNumbers FirstdataTXT SeconddataNumbers FirstdataTXT SeconddataNumbers FirstdataTXT SeconddataNumbers |
|
| Author: | Singularity [ Sun Feb 22, 2009 11:22 pm ] |
| Post subject: | Re: READTOARRAY COMMAND |
ReadtoArray just reads into the array. You can then loop thru the array and parse it using getWord if you need more specific parsing. |
|
| Author: | ElderProphet [ Mon Feb 23, 2009 11:21 pm ] |
| Post subject: | Re: READTOARRAY COMMAND |
readToArray textfile.txt myarray That command would take line 1 in the file "textfile.txt" and save it as $myarray[1]. And it would take the 2nd line in the file and save it as $myarray[2]. And so on. So if line 1 in the text file was "blob1 blob2 blob3", then you could use getWord to parse each word, like Sing said. Follow? |
|
| Author: | Yop_Solo [ Tue Feb 24, 2009 1:07 am ] |
| Post subject: | Re: READTOARRAY COMMAND |
Not sure, i got an answer from Vid and I decided to use 2 files for each information. But the best will be to have one file with 2 types of information in each. Example : Blabla 1 Bloblo 3 BluBlu 7 $Cat[1] = "Blabla" $Cat[2] = "Bloblo" $Cat[3] = "Blublu" $type[1] = "1" $type[2] = "3" $type[3] = "7" |
|
| Author: | LoneStar [ Tue Feb 24, 2009 1:59 am ] |
| Post subject: | Re: READTOARRAY COMMAND |
Yop_Solo wrote: Not sure, i got an answer from Vid and I decided to use 2 files for each information. But the best will be to have one file with 2 types of information in each. Example : Blabla 1 Bloblo 3 BluBlu 7 $Cat[1] = "Blabla" $Cat[2] = "Bloblo" $Cat[3] = "Blublu" $type[1] = "1" $type[2] = "3" $type[3] = "7" 2 Files Up to you, but that's totally unecessary. You can use any number of methods to seperate your data into 'columns'. You can use Coma-Seperated-Values (CSV), or insert a TAB Character (#9 in Twx scripting). These things will get around the issues of not always knwing how many Words there are to 'get' (even though that initself isn't a big deal). You might run into a big problem with continuity with your 2file method if one data file has X-number of Rows, and the second file has (X +/- n) Rows. |
|
| Author: | Singularity [ Tue Feb 24, 2009 4:36 am ] |
| Post subject: | Re: READTOARRAY COMMAND |
Right. A space separated list is the easiest, but if your data contains spaces then use a CSV. A CSV would take, eh, mebbe 3 extra lines to parse? |
|
| Author: | Yop_Solo [ Wed Feb 25, 2009 10:09 pm ] |
| Post subject: | Re: READTOARRAY COMMAND |
Seems to be a cool technique, but could you put an example to understand how to use it please. |
|
| Author: | ElderProphet [ Wed Feb 25, 2009 10:39 pm ] |
| Post subject: | Re: READTOARRAY COMMAND |
If you would provide some actual data that you are trying to save and retrieve from files, then we'll be able to help you with actual code. |
|
| Page 1 of 1 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|