Computer Science Canada

Picture Loaded in Condition Statement?

Author:  [Gandalf] [ Sun May 22, 2005 9:22 pm ]
Post subject:  Picture Loaded in Condition Statement?

I didn't know how else to state this problem.

How you check if there is a certain picture loaded in an if statement. For example, what I tried, which obviously didn't work is:

code:

var pic := Pic.FileNew ("pic.bmp")
if pic := Pic.FileNew ("pic.bmp") then
    put "this picture is loaded"
else
    put "there is no picture loaded"
end if


Do I have to make some boolean condition true when the pic is loaded, and then check for that? It seems like too much hastle...

Author:  Delos [ Sun May 22, 2005 9:39 pm ]
Post subject: 

Check the Error.Last and Error.LastMsg things. They return values after Pic.New is called, so you can use them to determine whether or not the pic has loaded.

Author:  [Gandalf] [ Sun May 22, 2005 9:51 pm ]
Post subject: 

Hmm, can you explain this a bit more? How do you use Error.Last and Error.LastMsg? If I add what I posted previously, the program doesn't even compile...

Author:  Bacchus [ Sun May 22, 2005 10:51 pm ]
Post subject: 

just check to see if the var = 0, if it does then the pic wasnt created Razz

Author:  MysticVegeta [ Sun May 22, 2005 10:55 pm ]
Post subject: 

unsuccessful pic open error is error # 201

Author:  zylum [ Mon May 23, 2005 12:25 am ]
Post subject: 

code:
var pic := Pic.FileNew ("pic.bmp")
if Error.Last not= 0 then
    put "this picture is loaded"
else
    put "there is no picture loaded"
end if

Author:  Cervantes [ Mon May 23, 2005 8:01 am ]
Post subject: 

Heh, you've got it backwards, zylum. Error.Last returns zero if there is no error.
Turing:

var pic := Pic.FileNew ("pic.bmp")
if Error.Last = 0 then
    put "this picture is loaded"
else
    put Error.LastMsg
end if

Author:  MysticVegeta [ Mon May 23, 2005 9:28 am ]
Post subject: 

Gandalf do you mean if the pic is already open? or the importing file error?

Author:  zylum [ Mon May 23, 2005 9:44 pm ]
Post subject: 

Cervantes wrote:
Heh, you've got it backwards, zylum. Error.Last returns zero if there is no error.


yup, you're right Wink

Author:  [Gandalf] [ Tue May 24, 2005 10:55 pm ]
Post subject: 

Thanks for all that, I was looking for something else, but this helps too.

I found a simple way of doing what I wanted, I was just doing things the wrong, redundant way... Thanks for all the help.


: