| Author |
Message |
|
Yop_Solo
Gameop
Joined: Mon Jan 26, 2009 12:27 am Posts: 123
|
 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
_________________ Dodger known as Yop Solo, Sysop twgsdodgerbbs.ath.cx http://cyberquebec.ca/_layout/?uri=http://cyberquebec.ca/twgsdodgerbbs/
|
| Sun Feb 22, 2009 10:10 pm |
|
 |
|
Singularity
Veteran Op
Joined: Thu Jun 02, 2005 2:00 am Posts: 5558 Location: USA
|
 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.
_________________ May the unholy fires of corbomite ignite deep within the depths of your soul...
1. TWGS server @ twgs.navhaz.com 2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads 3. Open IRC chat @ irc.freenode.net:6667 #twchan 4. Parrothead wrote: Jesus wouldn't Subspace Crawl.
*** SG memorial donations via paypal to: dpocky68@booinc.com
|
| Sun Feb 22, 2009 11:22 pm |
|
 |
|
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1134 Location: Augusta, GA
|
 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?
_________________ Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.
|
| Mon Feb 23, 2009 11:21 pm |
|
 |
|
Yop_Solo
Gameop
Joined: Mon Jan 26, 2009 12:27 am Posts: 123
|
 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"
_________________ Dodger known as Yop Solo, Sysop twgsdodgerbbs.ath.cx http://cyberquebec.ca/_layout/?uri=http://cyberquebec.ca/twgsdodgerbbs/
|
| Tue Feb 24, 2009 1:07 am |
|
 |
|
LoneStar
Commander
Joined: Fri Jun 09, 2006 2:00 am Posts: 1401 Location: Canada
|
 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.
_________________ ---------------------------- -= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
|
| Tue Feb 24, 2009 1:59 am |
|
 |
|
Singularity
Veteran Op
Joined: Thu Jun 02, 2005 2:00 am Posts: 5558 Location: USA
|
 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?
_________________ May the unholy fires of corbomite ignite deep within the depths of your soul...
1. TWGS server @ twgs.navhaz.com 2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads 3. Open IRC chat @ irc.freenode.net:6667 #twchan 4. Parrothead wrote: Jesus wouldn't Subspace Crawl.
*** SG memorial donations via paypal to: dpocky68@booinc.com
|
| Tue Feb 24, 2009 4:36 am |
|
 |
|
Yop_Solo
Gameop
Joined: Mon Jan 26, 2009 12:27 am Posts: 123
|
 Re: READTOARRAY COMMAND
Seems to be a cool technique, but could you put an example to understand how to use it please.
_________________ Dodger known as Yop Solo, Sysop twgsdodgerbbs.ath.cx http://cyberquebec.ca/_layout/?uri=http://cyberquebec.ca/twgsdodgerbbs/
|
| Wed Feb 25, 2009 10:09 pm |
|
 |
|
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1134 Location: Augusta, GA
|
 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.
_________________ Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.
|
| Wed Feb 25, 2009 10:39 pm |
|
 |
|