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 / Display Object Label Function

Author
Message
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 1st Jul 2006 17:29
I am making a function to display info when you click on different objects. Few problems tho!
1. When you click on anything but an object the program crashes.
I have tried putting If obj=0 exit function commands, cant seem to get it tho!
2. It wont print the variable. (it does print text tho if you replace the string variable with just text)


Global Sign="A" as string

Do
Other stuff

DisplayObjectInfo()
loop

function DisplayObjectInfo()
If mouseclick()=1
obj=pick object (mousex(),mousey(),1,2)
center text object screen x(obj)-40,object screen y(obj),Sign$
endif
endfunction

Attachments

Login to view attachments
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 1st Jul 2006 18:00
You aren't defining Sign$ in the function for one thing, so if it isn't global, of course it won't show anything, cause it is displaying ""!

not sure why the crash though!

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

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 1st Jul 2006 21:11
But havent I defined Sign as a global variable at top of code???

How would you write the function to exit if obj=0?
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 1st Jul 2006 21:36
Sorry, having a bad day!
I missed the line
Global Sign="A" as string

but, this syntax is wrong anyhow!
It should be:
Global A as string
Sign = "A"

To prove my point, try this:

You don't get anything, whereas

You get an "a"

And even then, your function is looking for Sign$, a different variable altogether!
e.g.

fails to print an "a"!

I've put in a clause to check for obj=0, and it works, no crashes, and I have nothing on-screen!

Try it in a new blank project.

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

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 1st Jul 2006 21:49
Thanks, Yes that works now, I was leaving a space between exit and function and the compiler obviously wouldnt accept it!

How would I now get the info to stay on screen after the mouse button is released then hidden again after it is clicked again?
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 1st Jul 2006 23:17 Edited at: 1st Jul 2006 23:18
Have a global flag for whether the data should be displayed. Also have a global variable for the selected object.

Then you can do something like this:


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

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 1st Jul 2006 23:42
Ok thanks, I'll have a play with that!

Login to post a reply

Server time is: 2024-11-26 17:25:30
Your offset time is: 2024-11-26 17:25:30