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.

Newcomers DBPro Corner / Read variables back from file

Author
Message
Dennuz666 v2
20
Years of Service
User Offline
Joined: 21st Jan 2004
Location: Netherlands
Posted: 20th Feb 2004 16:40
I want to save 'waypoint' data in a file.
I created this (read and write strings didn't work):



How do i get the same variables back in memory after loading the file. This returns all zero's:



Anyone knows a simple way of doin' this?

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 20th Feb 2004 18:19
Perhaps because you are writing data from an array of floats to the file with the write long command. Try WRITE FLOAT and READ FLOAT.

Also if the file allready exists the open to write command will fail. So do,
if file exist("track1.wps") then delete file "track1.wps"
open to write 1,"track1.wps"

Our civilization faces three great dangers. The first is destruction by a nuclear war, the second is being crippled with overpopulation and the third is the Age of Leisure.
Dennuz666 v2
20
Years of Service
User Offline
Joined: 21st Jan 2004
Location: Netherlands
Posted: 20th Feb 2004 20:01
That works! How do i know what type of command to use for different values. So i use Write Float for arrays... and...??? Isn't clear in de DBP helpfile i think.

Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 20th Feb 2004 20:11
just in case there is some misunderstanding, this does not mean arrays can only store floats, you use write float for arrays that hold floats, if they hold strings then you use write string, and if they hold small values under 255 or between -127 and 128 then use write byte (for compactness) and for larger integers use write word or write long, cheers.

Mentor.

System spec : Pentium 3.0Ghz, 512MB DDR, 2x160Gb HD (using icewave hd coolers ), DVD RW/CD RW (all modes), multimedia front panel, 6 way surround sound, ATI radeon 9800Pro 128mb.
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 20th Feb 2004 23:00 Edited at: 20th Feb 2004 23:01
The data type tutorial will explain about all the different data types.
http://developer.thegamecreators.com/?f=dbpro_tutorials

There is also a page in the dbpro help,
home > priciples > data types and variables

Our civilization faces three great dangers. The first is destruction by a nuclear war, the second is being crippled with overpopulation and the third is the Age of Leisure.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 21st Feb 2004 07:04
There is another way of saving arrays and you don't need to check if the file is there and it's appendable. try the `Array' command it starts on page 11 - 15 of the big manual or for a quick list of commands page 39 small manual.

In Space No One can Hear You Scream! (When your comm Line is cut?)

Login to post a reply

Server time is: 2024-11-26 05:58:37
Your offset time is: 2024-11-26 05:58:37