How can I display the value of a variable, without dialogs?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How can I display the value of a variable, without dialogs?
Finally got around to giving LiveCode a look (unfortunately 21 days after installing the demo, so only 9 days left for testing), and cannot seem to find anyway to display the value of a variable. For example, if I had a variable called "currentUser" and wanted to have its value (the name of the currently logged in user or "None") displayed at the top right of the main stack, and updated whenever its value changes ....
Also, really disappointed in the documentation available for LiveCode .. first two of their introductory vids are missing from their YouTube uploads (probably the only vids that would have shown some of the actual features of the language too) ... even the RunDev UserGuide doesn't use hyperlinks or have a useful (hyperlinked) index.
Also, really disappointed in the documentation available for LiveCode .. first two of their introductory vids are missing from their YouTube uploads (probably the only vids that would have shown some of the actual features of the language too) ... even the RunDev UserGuide doesn't use hyperlinks or have a useful (hyperlinked) index.
Re: How can I display the value of a variable, without dialogs?
Hi Rupes,
welcome to the forum.
You probably would want to use a field for that.
How to update the field is another matter. It all depends how a user logs in. That should trigger something that in turn updates the field.
If you want to do the check periodically then you would have to query the state of a user/users being logged in or nobody being logged in.
You could do that with a 'send in time' command.
code could look like this in a button.
this is a simple way to do a recurrent task
Is it something like this you are after?
Kind regards
Bernd
welcome to the forum.
You probably would want to use a field for that.
Code: Select all
put myVariable into field "myField"
If you want to do the check periodically then you would have to query the state of a user/users being logged in or nobody being logged in.
You could do that with a 'send in time' command.
code could look like this in a button.
Code: Select all
-- declare a script local variable which stays
-- with the current script and is accessible from every handler in
-- this script
local sWatchForUsers = false
on mouseUp
if sWatchForUsers is false then
put true into sWatchForUsers
send watchThem to me in 10 milliseconds -- start the timer
else
put false into sWatchForUsers
end if
end mouseUP
on watchThem
if sWatchForUsers = true then
-- here pseudocode since I dont know how you know if there is someone logged in, suppose have to query that
-- code for query here
-- and suppose the local variable tmyquery_for_someone_logged_in would true or false
-- and the nameOfUser contains the name of the user
if tmyquery_for_someone_logged_in is true then
put nameOfUser into field "myField"
else
put "none" into field "myField"
end if
send watchThem to me in 5 seconds -- this goes on until you click again and sWatchForUsers is false then the message will not be send
end if
-- here sWatchFolder is not true and no watchThem is send to me -> end of timer
end watchThem
Is it something like this you are after?
Kind regards
Bernd
Re: How can I display the value of a variable, without dialogs?
Thanks for the reply, but a field would not be appropriate as the user would never actually be entering any text, text would simply be displayed. I'm sure it is possible to replicate what I'm requesting using the field 'button', but that would be a very clumsy way to do what I'm asking about and would seeming require a lot of additional coding for such a simple function.
I can't believe that I haven't been able to find a way to do this, screen output is a basic function of all application languages, I must be overlooking something.
I can't believe that I haven't been able to find a way to do this, screen output is a basic function of all application languages, I must be overlooking something.
Re: How can I display the value of a variable, without dialogs?
I think you're thinking that fields must be enterable; quite the contrary - the "label" object that you pick from the LiveCode tool palette is actually a field with some properties set differently than those for enterable fields (lockText is true, showBorder is false, opaque is false, etc.).rupes wrote:Thanks for the reply, but a field would not be appropriate as the user would never actually be entering any text, text would simply be displayed. I'm sure it is possible to replicate what I'm requesting using the field 'button', but that would be a very clumsy way to do what I'm asking about and would seeming require a lot of additional coding for such a simple function.
I can't believe that I haven't been able to find a way to do this, screen output is a basic function of all application languages, I must be overlooking something.
Simply put a label field in the corner of your window and remove the default contents from it so it's empty. Give it a name (like "UserName") and then when you want to show something to the user, just execute:
Code: Select all
put currentUser into field "UserName"
Ken Ray
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Re: How can I display the value of a variable, without dialogs?
Yup, having some background with other programming languages and database work, "field" always equated to "an object that allows the user to enter data". They probably should have changed the name to avoid confusion. Of course better documentation would also help. Is there a post or table that lists common tasks done in other languages and their LiveCode equivalent? I'm willing to do a little research but with only 8 days left on my trial, I may just end up abandoning this software due to poor documentation .. if I hadn't found this forum with google, I'd still be hunting for the answer to the abovekray wrote:I think you're thinking that fields must be enterable; quite the contrary - the "label" object that you pick from the LiveCode tool palette is actually a field with some properties set differently than those for enterable fields (lockText is true, showBorder is false, opaque is false, etc.).rupes wrote:Thanks for the reply, but a field would not be appropriate as the user would never actually be entering any text, text would simply be displayed. I'm sure it is possible to replicate what I'm requesting using the field 'button', but that would be a very clumsy way to do what I'm asking about and would seeming require a lot of additional coding for such a simple function.
I can't believe that I haven't been able to find a way to do this, screen output is a basic function of all application languages, I must be overlooking something.
Simply put a label field in the corner of your window and remove the default contents from it so it's empty. Give it a name (like "UserName") and then when you want to show something to the user, just execute:Can't get much easier than that...Code: Select all
put currentUser into field "UserName"

Re: How can I display the value of a variable, without dialogs?
Also, I have to wonder just how bloated the resulting code for a LiveCode app is. How does it deal with all those other options available in the field object inspector, options that would never be needed for the simple display of the value of a variable on screen?
Re: How can I display the value of a variable, without dialogs?
I see you are coming from Java.rupes wrote:Also, I have to wonder just how bloated the resulting code for a LiveCode app is.
An app written with Livecode will have considerably less lines of code than an equivalent Java app...
Paul
Re: How can I display the value of a variable, without dialogs?
Well, one thing that isn't lacking with LiveCode is documentation... if anything, there is too much available.I'm willing to do a little research but with only 8 days left on my trial, I may just end up abandoning this software due to poor documentation

Beside the built-in dictionary and 380+ page user guide (pdf format) included with your trial, you might want to have a look at some of these:
http://lessons.runrev.com/
http://www.runrev.com/developers/lesson ... tutorials/
http://www.runrev.com/developers/lesson ... nferences/
http://www.runrev.com/developers/lesson ... -livecode/
http://www.runrev.com/developers/lesson ... -and-java/
Good luck,
-Doc-
Re: How can I display the value of a variable, without dialogs?
You'll find that in LiveCode there are several "base" objects, and that various properties/styles define look and behavior. For example, radio buttons, checkboxes, and push buttons are all "button" objects; sliders, scrollbars, and progressbars are all "scrollbar" objects, etc. In fact, if you open up the LiveCode Dictionary (last button on the toolbar), and then toggle open the "Objects" tree, you'll see all of these "base" objects listed there. The RunRev crew has just broken them out on the tool palette into separate "pseudo-objects" because it is more common to have each one of those forms as their own object, and it aids in transition from other languages (theoretically).rupes wrote:Yup, having some background with other programming languages and database work, "field" always equated to "an object that allows the user to enter data". They probably should have changed the name to avoid confusion. Of course better documentation would also help.
There is a smattering of comparisons here and there - there was a full document written comparing Revolution (what LiveCode used to be called) with RealBasic and Visual Basic - kind of a "head-to-head" along with sample code, etc.; for other languages not so much.rupes wrote:Is there a post or table that lists common tasks done in other languages and their LiveCode equivalent? I'm willing to do a little research but with only 8 days left on my trial, I may just end up abandoning this software due to poor documentation .. if I hadn't found this forum with google, I'd still be hunting for the answer to the above
Ken Ray
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Re: How can I display the value of a variable, without dialogs?
Try using:
set the label of this stack to whatEverVariable
then the name of the stack will be the variable you want.
set the label of this stack to whatEverVariable
then the name of the stack will be the variable you want.
Re: How can I display the value of a variable, without dialogs?
Stack? I thought a stack was more like a window. I guess I better try reading that manual again, from the very beginning.jsburnett wrote:Try using:
set the label of this stack to whatEverVariable
then the name of the stack will be the variable you want.
Re: How can I display the value of a variable, without dialogs?
A stack is more like a window, but he's suggesting to set the label of the stack to a value will change the window title in the titlebar. This is the same as setting the "title" property of the stack.
Ken Ray
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Re: How can I display the value of a variable, without dialogs?
Ah, ok thanks for clearing that up. I think I'm finally getting a better idea of how LiveCode approaches things .. a bit more like true OOPkray wrote:A stack is more like a window, but he's suggesting to set the label of the stack to a value will change the window title in the titlebar. This is the same as setting the "title" property of the stack.