View unanswered posts | View active topics It is currently Mon Apr 20, 2026 11:11 pm



Reply to topic  [ 8 posts ] 
 READTOARRAY COMMAND 
Author Message
Gameop
User avatar

Joined: Mon Jan 26, 2009 12:27 am
Posts: 123
Unread post 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
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 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
Image


Sun Feb 22, 2009 11:22 pm
Profile ICQ WWW
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post 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
Profile WWW
Gameop
User avatar

Joined: Mon Jan 26, 2009 12:27 am
Posts: 123
Unread post 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
Profile
Commander
User avatar

Joined: Fri Jun 09, 2006 2:00 am
Posts: 1401
Location: Canada
Unread post 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 :shock: :!: :?:

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
Profile ICQ YIM
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 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
Image


Tue Feb 24, 2009 4:36 am
Profile ICQ WWW
Gameop
User avatar

Joined: Mon Jan 26, 2009 12:27 am
Posts: 123
Unread post 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
Profile
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post 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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.