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 / Can i read and store variable in a file?

Author
Message
Oblivion
22
Years of Service
User Offline
Joined: 4th Nov 2003
Location:
Posted: 4th Nov 2003 09:04
i have a variable it's a and it's value is 0 i want it to change to a = 1
after reading a txt or a ini file or something
can someone please help me?
Genesis Rage
22
Years of Service
User Offline
Joined: 5th Oct 2003
Location:
Posted: 4th Nov 2003 10:27
you mean something like this?

open to read 1, "filename.txt"
a=1

close file 1
a=0

you may be asking for something esle... so try to explain exactly what you are looking for

OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 4th Nov 2003 12:44
Or do you want the variable to have the value read in ?


Avatar & Logo by Indi. Insert witty comment here...
Oblivion
22
Years of Service
User Offline
Joined: 4th Nov 2003
Location:
Posted: 4th Nov 2003 15:23
Or do you want the variable to have the value read in ?
yep
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 4th Nov 2003 15:35



To Survive You Must Evolve... This Time Van Will Not Escape His Fate!
Oblivion
22
Years of Service
User Offline
Joined: 4th Nov 2003
Location:
Posted: 4th Nov 2003 19:24
a as dword
temp as string
open to read 1,"config.ini"
read string 1,temp
a = val(left$(temp,3))
if a=0 then a=1
temp = "a=";a
write string 1,temp
close file 1

if i type this dbp tells me that temp = "a=";a isn't a valid code.
and if i do this won't i tell dbp that a=1 and not let dbp read it in my ini file
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 4th Nov 2003 20:11
Try this then :




Avatar & Logo by Indi. Insert witty comment here...
Oblivion
22
Years of Service
User Offline
Joined: 4th Nov 2003
Location:
Posted: 4th Nov 2003 21:22
yep this one works but still your not telling dbp to read a variable from the ini file but your telling it a = 1. wat i want to do is get a = 1 (wat's in my ini file) to replace a = 0 something like
open to read "ini.ini",1
read byte 1,a or read file 1,a
or something like that
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Nov 2003 00:55
Here's an extract from one of my libraries ... it uses the windows API to access windows-type ini files of this type :

[section]
key=value

Use full pathnames, otherwise in Win2K/WinXP it will write to a special area in the registry instead of a file.
Jess T
Retired Moderator
22
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 5th Nov 2003 05:16
Hey,
Have a look at my Codebase Entry, It's for DBC, but im pretty sure that it'll work fine for DBPro...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 5th Nov 2003 10:06
And I've got a plug-in for reading INI files too.


Avatar & Logo by Indi. Insert witty comment here...
Genesis Rage
22
Years of Service
User Offline
Joined: 5th Oct 2003
Location:
Posted: 5th Nov 2003 11:32
tries TCA's plugin... didnt like it to much (sorry)... but like IanM said there is some code that will use windows API to access the information...

http://developer.thegamecreators.com/?m=codebase_view&i=9779efa0c6e16b87a8eb34e5f0cf534d

this is some code i made easier to understand, and put in some examples and help information

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 5th Nov 2003 13:16
Quote: "yep this one works but still your not telling dbp to read a variable from the ini file but your telling it a = 1. wat i want to do is get a = 1 (wat's in my ini file) to replace a = 0 "


then read over my code again...
it grabs the value from the .ini translates it and then compares and puts it back.

you want a specific line version then fine, all you do is run off the non essential data and then replace.
and you can always use the byte read/write, but you'll have to translate the ansi values by hand for enter/tab/space/etc...


To Survive You Must Evolve... This Time Van Will Not Escape His Fate!

Login to post a reply

Server time is: 2026-07-26 16:04:09
Your offset time is: 2026-07-26 16:04:09