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 / Loading string

Author
Message
tubeular cube face
19
Years of Service
User Offline
Joined: 14th Jul 2005
Location:
Posted: 31st Jul 2006 15:38
I was tring to make itwork so that the string variable$ would save to a file on my computer and then load it into loaded$however it will not work.

[/code]
IF (file exist("E:\ Saved stuff\1\1"))=0
MAKE FILE "E:\ Saved stuff\1\1"
ENDIF

do
CLS

if shiftkey()=1
input ">",variable$
open to write 1,"E:\ Saved stuff\1\1"
write string 1,variable$
close file 1
GOTO HELLO
endif
LOOP

HELLO:
DO
CLS

open to read 2,"E:\ Saved stuff\1\1"
read string 2,loaded$
close file 2

print
print "VARIABLE = ",variable$
print
print "LOADED = ",loaded$

loop
[code]

Tubeularcubeface
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 31st Jul 2006 15:44
DarkBasic won't open a file to write if it already exists. Before you write it, you need to check if it exists and if so, delete it. Also, you have an infinite loop after HELLO:

CHESS ENCOUNTER
Demo
WIP
Trowbee
21
Years of Service
User Offline
Joined: 12th Apr 2003
Location: United Kingdom
Posted: 31st Jul 2006 22:44 Edited at: 1st Aug 2006 21:41
The path has to exist too, else it won't work.

Have a gander at this (edited to actually make it work ):


It saves directly to E:, so you'll have to adjust to suit your program.
tubeular cube face
19
Years of Service
User Offline
Joined: 14th Jul 2005
Location:
Posted: 1st Aug 2006 18:16
Ok that helps alot also how do you get the code snippet in a box like that?

Tubeularcubeface
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 1st Aug 2006 18:58
{code}

your code here

{/code}


but use [] instead of {}

Science, Mathematics, and Physics do not lie - only people do.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 3rd Aug 2006 17:45 Edited at: 3rd Aug 2006 17:46
I've got a question: Why, oh why does everybody put a "/" all over the place in their code!? How do they not notice it won't run? Not this, but people write things like this:

print /"/Hello"

Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 4th Aug 2006 15:19
It seems to be the configuration of some people's browsers that adds them in.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001

Login to post a reply

Server time is: 2024-09-25 05:23:27
Your offset time is: 2024-09-25 05:23:27