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 / open to read?

Author
Message
Slayer
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: CA
Posted: 23rd Feb 2004 00:10
I use this code and it wont work. I need to get a float out of
a .txt file.

open to read 1,""

x as float
z as float

read float 1,x : print x
read float 1,z : print z

close file 1

I dont know how to spell
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Feb 2004 04:27
first you have to specify a filename. then the file must contain a float in that order.

"eureka" - Archimedes
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 23rd Feb 2004 05:46
For example, create a new text file and type in "1.02" without the quote marks. Then save the file in the folder with your source code, and insert the file name into the quotes in the open to read command.

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 23rd Feb 2004 06:12
Read float only reads floats that where written with write float or with knoledge of how dbpro stores floats in files. It does not work with floats that are in the file as plain text.

If you have a text file with plain text then you need to use read string.

If you text file looks like this


You would need to read it using



you can also use read byte to read the file a byte at a time so you don't have to format the text file the way read string expects.

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.
Slayer
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: CA
Posted: 23rd Feb 2004 19:54
oook so then if I wont to read a float I have to write it with
open to write. I was just going to give up and just make a dll
to do it for me. This works out just fine, Thanks!

I dont know how to spell

Login to post a reply

Server time is: 2024-09-21 22:40:55
Your offset time is: 2024-09-21 22:40:55