Read/Data

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Hey Fred,
How about a quick lesson on how to use the new READ and DATA commands. I just get Syntax errors when I try.

Can you not list groups of data like:
DATA 1,2,3,4,5
DATA 6,7,8,9,10

I need some help here :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Cantor.

Hi!

I'm not Fred, but I'll answer You anyway.
Here my example:

; Begin Sourcecode

For i=1 To 10
Read a
result=MessageRequester("Data",str(a),#PB_MessageRequester_Ok)
Next

For i=1 To 10
Read a$
result=MessageRequester("Data",a$,#PB_MessageRequester_Ok)
Next

DataSection
Data.l 1,2,3,4,5,6,7,8,9,10
Data$ "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"
EndDataSection
;
; End Source Code.

I think You forgot to include the type of data that's listed in the Data Section,
i.e. "Data.l" or "Data$"
It's different between Pure Basic and other Basic dialects but I think that
doesn't matter.


--
Best regards,
Martin
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Thanks Cantor... You the man !!
I did not know I had to include the Type. I hope someone is working on updating the docs. There are quite a number of new commands now that have no documentation.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

So DATA seems to be an array, is this right?
And with READ it is possible to get the stored value?

It is possible to have more than 1 array with this command?




Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

DATA lets you hold information internally as opposed to reading it from an external file. For example, I'm using it to READ info into a 2 dimensional array...

Code: Select all

DIM info(4,4)
For x=1 to 4
  For y=1 to 4
    Read info(x,y)
  Next
Next

DataSection
 Data.l  2,2,2,2
 Data.l  2,4,4,2
 Data.l  4,4,4,4
 Data.l  2,2,2,2
EndDataSection
You can have as much data as you want and read it into any type of array you want.
Post Reply