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 Discussion / DarkBasic FINAL EXE program won't save Text Files but MAKE EXE does??

Author
Message
Azdreamer3d
9
Years of Service
User Offline
Joined: 19th Aug 2010
Location:
Posted: 21st Dec 2011 11:10
Hello,

A weird issue same code works, I can save txt files from the SAME PROGRAM CODE without modification.

I'm compiling two different ways using DarkEdit. If I just do MAKE EXE and have all the media and models in the same folder it will create and write a file. But if I do FINAL EXE when the program is suppose create and save a text file it doesn't.

The only difference is one is a FINAL EXE and has the embedded media and the other just an smaller sized plain old EXE . I just don't want to distribute all the separate media files cause Ill I gotta do is save a line of text. Been banging my head on this one for years and finnaly decided to ask! LOL

This does the same thing on Win XP, Vista and Windows 7, Anybody have any ideas?

Thanks in advance
~Paul
TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Dec 2011 00:02
Try this. Just before you make your final exe, delete the text file which is supposed to be created by your code.

I suspect that when you create the final exe, the text file is packed into the exe. So when you run the exe, it will try to write to the file contained within itself, but won't be able to. If you delete the file so it's not packed into the exe, it will be able to write to the text file.

TheComet

Benjamin
17
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 27th Dec 2011 02:50
A little unsure what you mean, but if your program is trying to create a text file it may just be that it's creating it in a different place than where you think.



Support a charitable indie game project!
Azdreamer3d
9
Years of Service
User Offline
Joined: 19th Aug 2010
Location:
Posted: 31st Dec 2011 18:28
Thank you for the replies. I never did find out why sometimes it would create the file and sometimes not. I compiled with and without the data.txt in the final exe. My solution was to get the current directory and force it to write in a specific place by adding get Dir$() at the top of the code. This post got me on the right direction - http://forum.thegamecreators.com/?m=forum_view&t=59148&b=10

ProgramDir$ = Get Dir$()

Then used it in the code below.
~Paul



SaveInfo:

MySavedInfo$ = ""

If SaveData=0
rem Delete file
if file exist(ProgramDir$ + "\datalast.txt") then delete file ProgramDir$ + "\datalast.txt"
wait 10

if file exist(ProgramDir$ + "\data.txt") then move file ProgramDir$ + "\data.txt", ProgramDir$ + "\datalast.txt"
rem delete file "C:\data.txt"
SaveData=1
wait 10
open to write 1,ProgramDir$ + "\data.txt"
rem wait 10
Bannertext$ = "Save Mode changed to 1"
wait 10
endif

if SaveData=1 or SaveData=2

rem Bannertext$ = "Saving Private Ryan"
rem wait 10

MySavedInfo$ = ("Count, " + str$(Count) + ", WinVal, " + RWinValue$ + " , RValTotal, " + str$(RValTotal) + ", " + Bannertext$ + ", Fwin, " + str$(Fwin))
write string 1,MySavedInfo$
SaveData=2

endif[href]null[/href]http://forum.thegamecreators.com/?m=forum_view&t=59148&b=10

Login to post a reply

Server time is: 2020-08-15 12:21:48
Your offset time is: 2020-08-15 12:21:48