Posted: 12th Jun 2007 4:25
Below is the snippet that's failing.

+ Code Snippet
do
        cls
        box 0,0,1024,768,rgb(255,0,0),rgb(255,0,0),rgb(255,0,255),rgb(255,0,255)
        if file exist(playerdata(1).name+".sav")=1
            messagebox("Are you sure you want to continue? Your file will overwrite.","Type yes to overwrite, type no to change your name.")
            if inputbox(0,-30,continue$)
                continue$=lower$(inputbox(0,-30,continue$))
                if continue$="yes"
                    goto _new_game
                else
                    goto _menu_new_game
                endif
            endif
        else
            make file playerdata(1).name+".sav"
            goto _new_game
        endif
    loop


This is really stumping me. If anyone has any comments (other than using gosub instead of goto) please post.
Thanks.
Posted: 12th Jun 2007 5:05
Another question: Is it possible to save an array defined as a UDT?
Example:

+ Code Snippet
Type playerdata
name as string
pos as vector
endtype
global dim playerdata(1) as playerdata
save array playerdata(1).name+".sav",playerdata(1)


Once again, thanks.
Posted: 13th Jun 2007 5:41
BUMP

I really don't see why...
Posted: 13th Jun 2007 5:49
You need to use 'Open To Write' most likely, as that will not only create a file but allow you to write to it, just make sure it doesn't exist before using this command.

Lastly No you cannot save arrays with use a UDT.

P.S. Don't use goto so much .
Posted: 13th Jun 2007 15:19
Don't use MAKE FILE, do use OPEN TO WRITE. Make sure the files does not exist with 'if file exist(Filename$) = 1 then delete file $Filename$' or equivalent before you open it to write to.
Posted: 13th Jun 2007 18:28
IanM: I can Open to write after the files there. It works fine. It won't detect the file though.... That's what I can't figure out
Posted: 13th Jun 2007 18:35
I finally got it to kind of work... I had to type Jim.sav though... But now, the loop is messing up badly...

Here's the code that's messing up:

+ Code Snippet
    do
        cls
        box 0,0,1024,768,rgb(255,0,0),rgb(255,0,0),rgb(255,0,255),rgb(255,0,255)
        messagebox("Please enter your name.","")
        if inputbox(0,-30,playerdata(1).name)
            playerdata(1).name=inputbox(0,-30,playerdata(1).name)
            exit
        endif
    loop
    do
        cls
        box 0,0,1024,768,rgb(255,0,0),rgb(255,0,0),rgb(255,0,255),rgb(255,0,255)
        if file exist("Jim.sav")=1
            cls
            exit
            exit
            exit
        else
            open to write 1,playerdata(1).name+".sav"
            close file 1
            goto _new_game
        endif
    loop
    do
        cls
        messagebox("Are you sure you want to continue? Your file will overwrite.","Type yes to overwrite, type no to change your name.")
        if inputbox(0,-30,continue$)
            continue$=lower$(inputbox(0,-30,continue$))
            if continue$="yes"
                goto _new_game
            else
                goto _menu_new_game
            endif
        endif
    loop


Any ideas? Thanks in advance.

[EDIT]
I think I found my error... I need another if after the else... so it doesn't keep repeating... Wow I'm stupid
Posted: 14th Jun 2007 4:59
FIXED! I added a second if file exist, and it works.... now why I needed two? who knows...