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 Professional Discussion / store values in files

Author
Message
Sam Cameron
21
Years of Service
User Offline
Joined: 26th Dec 2003
Location: 0,0,0 I\'m the center of the world !!!
Posted: 10th May 2004 14:27
Hello there, another of my stupids questions again , I need a code for still in the last value before out, something like this:






what I need it's a command to store into a filesystem (like .ini or something) the last value cubesize# before exit, and the same at the begining of the code for load the last value of the stored file (ini or whatever) I tried with "write file" and somethings, but it's store with different values, I'm confussed, any idea without plugins? because I saw some codes with plugins, or for string, and what I need it's for numbers,thanks in advance.
TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 10th May 2004 14:46
Someone made a plugin for reading/writing .INI files... but I don't remember who...

Finally got a new computer:
AMD Athlon Barton XP 3000+, 2x512 Dual DDR3200, Asus V9570/TD 256MB GeforceFX 5700, 200GB SATA 150 HD
Sam Cameron
21
Years of Service
User Offline
Joined: 26th Dec 2003
Location: 0,0,0 I\'m the center of the world !!!
Posted: 10th May 2004 14:56
yes I know but I preffer do not use plugins, etc... only code, and I don´t need .INI files, whatever type of files is well, only I need a code for store the values before exit and load when I run the program.
TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 10th May 2004 15:05
I don't have the manual with me, so this is written right out of my head... but something similar should work.

start of program:


end of program:


Finally got a new computer:
AMD Athlon Barton XP 3000+, 2x512 Dual DDR3200, Asus V9570/TD 256MB GeforceFX 5700, 200GB SATA 150 HD
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 10th May 2004 15:06
I have disabled escape key, so program can leave loop and write value to disk when you press escape, rather than escape quitting program straight away.

If you need any explanation of commands used, just ask.



Boo!
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 10th May 2004 15:41
if you decide to use a plugin to write files, I think ours it worth a look.


* DBP_NETLIB_v1 - VB.NET PLUGIN FOR DBP * Click Logo
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 10th May 2004 16:00
LOL at CattleRustler. You are getting worse than NuclearGlory at advertising your plugin (which I'm sure is as great as you say it is).

However I'm sure that forcing user to have .NET installed just to write a simple number to a file is probably not what SamCameron wants.

Boo!
Sam Cameron
21
Years of Service
User Offline
Joined: 26th Dec 2003
Location: 0,0,0 I\'m the center of the world !!!
Posted: 10th May 2004 16:10
Spooky I test you code and it works great, but I have some doubts, can I use without disable esc key??? because I want this code for possible crash and for backup again when I run, but with you code only store the values when ESC is pressed, so I need the same but when program exit (by the user, or by a crash). Another question can I store two or more different values in the same file? example:

cubesize#=70
spheresize#=50

in

filename.dat
???

thanks again, I love this forum !!
TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 10th May 2004 16:21
If you enable the ESC key, the application will exit emidiately when pressing ESC and you will not be able to write the values to a file. And there are no way (yet) to catch crashes in DBP.

Storing multiple values in the same files is no problem.. just copy the write float and read float lines... and make sure you read them in the same order as you wrote them.

Finally got a new computer:
AMD Athlon Barton XP 3000+, 2x512 Dual DDR3200, Asus V9570/TD 256MB GeforceFX 5700, 200GB SATA 150 HD
TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 10th May 2004 16:26 Edited at: 10th May 2004 16:26
Some time ago, I wrote a program that, using the write string command, wrote a string to a file every single loop of the application to see how much slow down that would create... and there were practically none...



If you write the values to a file every loop of the program, it will store the values till next time even if the program crashes... except if it crashes exactly on the write to file commands.. :-s

Finally got a new computer:
AMD Athlon Barton XP 3000+, 2x512 Dual DDR3200, Asus V9570/TD 256MB GeforceFX 5700, 200GB SATA 150 HD
1tg46
21
Years of Service
User Offline
Joined: 1st Feb 2004
Location: I dont know!
Posted: 10th May 2004 16:32 Edited at: 10th May 2004 16:34
The dll for reading and writing of INI files is at the homepage for TCA
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 10th May 2004 16:40 Edited at: 10th May 2004 16:41
@spooky,

well I am just trying to let people know that our plugin is out there and it has about 40 useful functions brought over from vb.net. If you're runnin xp you probably have .net framework installed although you need version 1.1. The redist is 26 megs download. XP sp2 will include it. Next ms os is pure .net. If you look thru the docs on the web link to the plugin I think most people would think that the .net requirement is worth what the plugin provides - not to mention what it will soon include. But I hear ya and you're right, I don't expect someone writing a file needing a plugin and .net, but if they want to use all of our functions I think it's well worth it.
Click the logo below and you can read the doc without dloading the library.

and oh yeah, we read and write ini files as well - just an fyi


* DBP_NETLIB_v1 - VB.NET PLUGIN FOR DBP * Click Logo
Sam Cameron
21
Years of Service
User Offline
Joined: 26th Dec 2003
Location: 0,0,0 I\'m the center of the world !!!
Posted: 10th May 2004 19:44
I don't want any DLL or plugin, only code, I think I'm very close to get it (thanks some people of this post) at the moment I have one doubt, the code work when it exit from the loop, example:


but do not work when I put the code directly in the loop, like the cyborg code:



maybe cause I'm using float numbers? or I don't know, but I want to write information without exit the program, in every loop.
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 10th May 2004 20:05
Of course you can get rid of the escapekey stuff and just have it save when user presses a particular key. This code will only save settings when you press SPACE.



@CattleRustler - I have ADSL and so have all the windows updates installed, including .NET framework. I have found there are more and more shareware utilites that require its installed. Specially MSDE and SQL management programs which I'm getting into.

Boo!
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 10th May 2004 20:12
yes, and that trend will only continue


* DBP_NETLIB_v1 - VB.NET PLUGIN FOR DBP * Click Logo
Sam Cameron
21
Years of Service
User Offline
Joined: 26th Dec 2003
Location: 0,0,0 I\'m the center of the world !!!
Posted: 10th May 2004 21:41
DONE !!!! thanks guys, spooky great code, very useful

Login to post a reply

Server time is: 2025-05-28 05:00:11
Your offset time is: 2025-05-28 05:00:11