Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / loading from file

Author
Message
Sepultura
22
Years of Service
User Offline
Joined: 7th Mar 2003
Location:
Posted: 13th Mar 2003 15:53
ok what i want to do is load numbers 0,1,2,3 from a file .txt or something and store the numbers in a array
is it possible? can i have the file like:
01222210 ect in the file and read of each digit liek a
11222110 coordanite like 1,1 would be 0 and 2,2 is a one?
11111110 any help would be great ... also if i use plains
00000000 in a game instead of sprites does it slow the
game down i was considering useing textured plains for my map tiles instead of sprites
thx
sep
Zach
22
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: Ms, USA
Posted: 13th Mar 2003 19:04
you Could Make an array and store the numbers in that...

I don't Know if this is what you mean but it could help..



Then you could load it back in like this...



Tupelo, Ms
Sepultura
22
Years of Service
User Offline
Joined: 7th Mar 2003
Location:
Posted: 14th Mar 2003 00:55
just say i tyoed up a text file can i make db read off it using line numbers and coloms??

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 14th Mar 2003 02:11
open to read [file],filename$
read string [file],strVariable$
close file [file]

[file] is a value 1 to 32
filename$ is the file you want to lead from
strVariable$ is what is read from the file

a string command will read each line from an ascii file with upto 255 character per line (else you'll overflow the string data)

you can then take these values and put them into an array like so

dim a(256)
for x = 1 to len(strVariable$)
a(x) = val( chr$( asc( right$( strVariable$,x ) ) ) )
next x

i know this looks a little convoluted, but all this does is makes a string position from the right most number (so say you have 8 numbers '12345' it'll make the string from the right so '5' ''45' '345' etc...) it'll then convert the first number of this string into an ascii version ... and then convert it back into its string character version ... and finally it'll turn that string number into a value number

(all len does is grab the number of characters in the string)



Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
large_nostril
22
Years of Service
User Offline
Joined: 5th Feb 2003
Location: United States
Posted: 14th Mar 2003 02:37
"dim a(256)"

instead define the array as:

DIM a(LEN(strVariable$))

it doesn't have the extra residual elements of the array. At least that's what I use.

If you want fresh underwear in the morning, take it off the night before.
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 14th Mar 2003 03:41
yeah probably a better would be that, and using the mid$ command instead of the right$ one ... don't think it matters greatly how its done in the end though



Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?

Login to post a reply

Server time is: 2025-05-16 11:19:51
Your offset time is: 2025-05-16 11:19:51