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 / Saving In DarkBasic Classic... I need help

Author
Message
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 10th Oct 2003 02:32
Hi,
I was wondering how I could save in DBC. I have looking through the help menu's and I kinda understand but not quite.

Say I have these variables:
charhp#=200
charmp#=50
charstr#=100
charname$="Smokiemcpot" (as if it were inputed though)

How would I save those into a file? Would it look like this?
open to write 1,"char1.dat"

write charhp#
write charmp#
write charstr#
write charname$
close file 1

Would it look like that? Am I close? Please help me out using my variables.

Thanks
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*Future Number: Eleventy
PoHa!84
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 10th Oct 2003 02:57
If I'm not wrong that would be correct, except that you need to make them:

write byte 1, charhp#
etc....


Destroy you with my mind, I could!
. Cool, he is. Play his games, I do.
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 10th Oct 2003 03:06
Why would it be write byte though. What does that mean? I know what a byte is but I dont know the purpose of typing it in this code.

Well ya I got that code to work but here is my problem.

First: Wont let me save strings$... Only Integers#
Second: Can't get it to load up. Let me paste what I got.



How would I load that? I know I would do a:
open to read
but I am not sure on everything

Thanks
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*Future Number: Eleventy
PoHa!84
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 10th Oct 2003 03:14
To save a string, you have to do this:

write string 1, charname$

Quote: "Why would it be write byte though. What does that mean? I know what a byte is but I dont know the purpose of typing it in this code."


I'm not sure what you mean by all that.

You would open to read, then:



If I'm correct, once it reads one part of the file, it goes on to the next. But I'm not 100% certain on that. Someone else should probably post, or you should try it.

Destroy you with my mind, I could!
. Cool, he is. Play his games, I do.
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 10th Oct 2003 03:16
Darn,
I got what I just posted to work... The only thing I didnt get yet was.

I made a completely new .dba and I set it to read the test.dat
when it reads it turns out like this:
0
0
0
SmokieMcPot

Now in the .dba that saved all my integers it worked when I saved then read.

In this new one it wont read the integers. Why not?

Thanks
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*Future Number: Eleventy
PoHa!84
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 10th Oct 2003 03:48
Dunno. Honestly, I don't. Do you have your commands in the right order? (i.e. read byte, ect?) Sounds strange....

Destroy you with my mind, I could!
. Cool, he is. Play his games, I do.
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 10th Oct 2003 04:13
Here let me give you the code I got for both .dba files. They are both saved to the same project folder also.





Maybe that will help you out. Instead of printing the correct integer numbers it replaces them with zero. It does print out the correct string though. Tell me what I did wrong.

Once again you are on the ball.

Thanks
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*Future Number: Eleventy
PoHa!84
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 10th Oct 2003 04:22
Man, that is weird. I'm playing with it, but it could be awhile. Also, I've not messed with these commands that much, so I might have posted some inaccurate info, I'm not sure. I'll check back in after awhile...

Destroy you with my mind, I could!
. Cool, he is. Play his games, I do.
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 10th Oct 2003 04:27 Edited at: 10th Oct 2003 04:31
This code works



Yours doesn't work because you are doing "read byte 1,charhp#"
You need to read a byte into a variable or a byte. The "#" at the end of charhp# makes it a float and if you read a byte into a float rather than giving an error it does nothing.

Edit:
If the variables you are using with the "#" at the end are floats in your game then save them with the "write float" command otherwise you will lose everthing on the right side of the decimal point.
PoHa!84
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 10th Oct 2003 04:28
Alright Smokie. I got it to work. I might have made more changes than actually necessary though.





Destroy you with my mind, I could!
. Cool, he is. Play his games, I do.
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 10th Oct 2003 04:36
Wow thanks dude works like a charm.

Now its time for me to try to figure out how to make a single variable that saves a whole character into it. Like this:
archerstats(1)

but inside that variable there is
strength#=10
hp#=10
mp#=5

Is it possible to do that in DBC. I know in dark basic pro there is a type command like.

type potion
stuff in here
endtype

I dont know I saw it somewhere.

Let me know if you know what I'm talking about in classic.

Thanks
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*Future Number: Eleventy
PoHa!84
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 10th Oct 2003 05:15
You could do that with arrays and several three write byte commands.

Destroy you with my mind, I could!
. Cool, he is. Play his games, I do.

Login to post a reply

Server time is: 2024-09-21 04:11:22
Your offset time is: 2024-09-21 04:11:22