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 / Writing Strings

Author
Message
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 28th May 2007 12:46
Okay, i'm trying to write some data (a float), as a string to a .DAT file. There's 2 variables I want to write, both floats, and they determine the X and Y resolution of the gaming window.

Firstly, I declared the two variables like so:



Then, I asked the user what they want to make the resx and resy values like this:



Then, I write the resx# and resy# values to a .DAT file, using this:



Except all it does is keep writing the default values of the resx# and resy# variables to the file, not the values that the user inputs.

Thanks for your time, as always.


[center]
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th May 2007 13:47 Edited at: 28th May 2007 13:53
I'd do it like this:




and your variables aren't floats, there just integers. a float has digits after the decimal point. to make them floats do it like this:


all though for this particular application, you dont need float values, as a screen's resolution is never a decimal.
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 28th May 2007 14:04
Hmm, good idea! I never thought about using arrays! Thanks!


[center]
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th May 2007 14:30
The advantage writing strings has over writing arrays is that you can open the file afterwards in Notepad and check that your program wrote what you thought it should have.

The code you were using looks OK, so it must be something elsewhere that is causing the problem.

If you want an easy way to write INI files instead, take a look at this:

http://forum.thegamecreators.com/?m=forum_view&t=106556&b=6

TDK_Man

Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 30th May 2007 10:59
Hmm, now i'm having a problem with the arrays, saving and loading them.

This is the code im using to get the information in the array, and then save the array to a file:



Then, in a different program, i'm using to load and read the info from the array:



And then a bit further down:



Problem is, the array doesn't even save, the file isn't even created! What's wrong here?


[center]
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Jun 2007 05:12
Are you sure you ever return from the ask_questions3() function?

My only experience with saving arrays has been with DBC and it didn't work properly far too much. That's why I switched to using the method employed in the post I linked to above.

DBPro has probably long been free of the bugs I'm talking about.

If you can't get it working and aren't using huge arrays with lots of items to save, you could use the INI files function. (You can give the file any name you choose - it doesn't have to be a .INI file BTW).

TDK_Man

Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 1st Jun 2007 10:07
Yaarg! Yeah, i'm definently returning from the function, and even tried turning it into a GOSUB command to see what happened, but nope, still no array file created. Anybody else know of any problems?

PS: TDK, if you don't mind, do you think I could e-mail you the whole source code to look at? (I'm not really wanting to put it up here...)

Thanks all!


[center]
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 1st Jun 2007 14:24
Not exactly sure, I think 0 is meant to replace the number of the array, but about half an hour ago I re-wrote the whole array reading/writing system and it works fine now, but I still don't know what was wrong with it before.

But anyway, thanks for your help everyone.


[center]
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 1st Jun 2007 14:37
Really? My array loading works fine now and i'm not using 0, i'm using 1.


[center]
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 1st Jun 2007 15:00
Heh, yeah, i'll give it a shot.


[center]
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 2nd Jun 2007 02:50
Argh, another problem,but I don't want to start a whole new thread for it, so here it is.

I'm trying to play an animation, with these commands:


But the animation doesn't play, the game starts, and then closes again straight away. It plays if I put a WAIT 9000 before the CLS code, but I don't want it to wait, I just want the animation to play, then move on to the showbg code. Oh, and yes, the animation definently exists.

So what's wrong here?

All help appreciated, as always.


[center]
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 3rd Jun 2007 04:38
*Bump* Any help?


[center]
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 5th Jun 2007 10:15
Cmon guys, I need the help here!


[center]
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 5th Jun 2007 10:36
In order to get mutliple animations to work, you need to record the actions from the player and then set some conditions from it.

Having just stripped down my game and testing this it works for me.

Hopefully this will help.

I used to live in surry hills / newtown and south coogee plus manly mate



Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 5th Jun 2007 12:44
Hmm, im using the PLAY ANIMATION command to play an .AVI file.

This is the full code i'm using:



I'm not sure how the code you posted works, but I appreciate it all the same.

Quote: "I used to live in surry hills / newtown and south coogee plus manly mate "


Really? I'm up in the Blue Mountains now, but, strangely enough, I go for the Brisbane Broncos in the NRL!


[center]
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 5th Jun 2007 13:17
ahh nice place to live mate.

Sorry I was not looking close enough however if you replace my loop animation for playing video the concept of code should work the same.

If you want contextual help on the AVI post up a sample sized version of the avi in question.
reduce its size way down and then it will be easy to post.

It might be a codec thats not playing it.
I will take a stab later after some food.


ps I live near suncorp stadium but not so much a footy fan
when the games are on my street gets flooded with cars and revelers

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 5th Jun 2007 13:23
Before i grab food, sorry to double post on you but i just remembered I answered a video playing question a while back.

does your avi work for you in this example. that will tell you if the codec is right for DBP.



Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 5th Jun 2007 13:37
Yeah, the above code works perfectly with the file, so it must be the code i'm using.


[center]
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 5th Jun 2007 14:16
ok so something like this might help with your code.


Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 6th Jun 2007 09:54
Hmm, nope, the program just starts up and stops again immdeiately.


[center]
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 7th Jun 2007 05:42
create a few suspend points and print out the variables to the screen your trying to follow.
stop the program where you think its going wrong and keep falling through the code until you suspect another position.


sync
suspend for key

etc//

Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 7th Jun 2007 11:34
Yeah, in the end I solved it, but i've forgotten what I did to solve it...

Anyway, here's the code if you're interested:



Thanks for all youe help everyone!


[center]
Vidiot
18
Years of Service
User Offline
Joined: 15th May 2006
Location: TN
Posted: 11th Jun 2007 03:08
I had a lot of trouble tring to go back and forth between playing a series of stills, videos, and flash files, until I learned to turn SYNC OFF whenever I wanted to play a video, then use a WAIT X until the video was over. Then turn SYNC ON again.

The answer to Life, the Universe, and Everything? "Tea for Two". Deep Thought was Dyslexic.

Login to post a reply

Server time is: 2024-11-25 17:49:30
Your offset time is: 2024-11-25 17:49:30