1. Save Bug

Hello,

I think this may be a bug. Whenever I goto write data to a file, my program crashes on me. Here is the code.

 
constant HP = 1 
integer handle 
sequence file, fName 
 
fName = getSaveFileName(Main,file,FrostType) 
 
 if length(fName) = 0 then 
        return 
 end if 
 
 print(handle,HP) 
 puts(handle,"\n") 
 
 close(handle) 
 
new topic     » topic index » view message » categorize

2. Re: Save Bug

Andy said...

Hello,

I think this may be a bug. Whenever I goto write data to a file, my program crashes on me. Here is the code.

 
constant HP = 1 
integer handle 
sequence file, fName 
 
fName = getSaveFileName(Main,file,FrostType) 
 
 if length(fName) = 0 then 
        return 
 end if 
 
 print(handle,HP) 
 puts(handle,"\n") 
 
 close(handle) 
 

I don't see where your getting a handle from ?

new topic     » goto parent     » topic index » view message » categorize

3. Re: Save Bug

bernie said...
Andy said...

Hello,

I think this may be a bug. Whenever I goto write data to a file, my program crashes on me. Here is the code.

 
constant HP = 1 
integer handle, fn 
sequence file, fName 
 
fName = getSaveFileName(Main,file,FrostType) 
 
 if length(fName) = 0 then 
        return 
 end if 
 
  handle = open(fName,"wb") 
 
 if handle = -1 then 
 
  fn = message_box("Save Error", 
                  "Save File Error", 
         MB_TASKMODAL) 
 end if 
 
 print(handle,HP) 
 puts(handle,"\n") 
 
 close(handle) 
 

I don't see where your getting a handle from ?

Oh sorry. Anyways, I have corrected the code now. Can someone maybe see why there is a bug?

new topic     » goto parent     » topic index » view message » categorize

4. Re: Save Bug

handle is probably -1... put a return in the "if handle =-1 then" block and see if that fixes it.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Save Bug

euphoric said...

handle is probably -1... put a return in the "if handle =-1 then" block and see if that fixes it.

No, that didn't fix it. It also happens when I try to load the data as well. Also, after the program crahses. The cursor in the editor goes back to fName position.

IE: | fName = getSaveFileName(MainWin,file,FrostType)

I think it may have to do with something in the fName variable, but I'm not sure why, as I have it declared correctley, for how I want to use it.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Save Bug

Hi

Where did it crash, and whats the crash message?

Chris

new topic     » goto parent     » topic index » view message » categorize

7. Re: Save Bug

Andy: I don't know what getSaveFileName function you are using but some libraries do not just return JUST the file name.

The filename sequence may contain additional information in the sequence so that you need to use a index to get the filename.

Print out the filename sequence and look at it.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Save Bug

bernie said...

Andy: I don't know what getSaveFileName function you are using but some libraries do not just return JUST the file name.

The filename sequence may contain additional information in the sequence so that you need to use a index to get the filename.

Print out the filename sequence and look at it.

Ah, I have figured it out. the "file" variable needed to be like this.

file = ""

Now it works fine. Thanks

new topic     » goto parent     » topic index » view message » categorize

9. Re: Save Bug

Andy said...

Ah, I have figured it out ...

That's great. However, next time you need some help with a problem like this, you should actually give us the error message(s) you got and maybe the relevant parts of any ex.err file created. Asking "what's wrong with this ..." is nearly always not enough information for us to go by.

Anyhow, glad you got it fixed.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu