Something strange...

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Something strange...

Post by cmhjon » Mon Jun 12, 2017 8:17 pm

Hi everyone,

I am building a very simple stack with a few buttons and text fields. After I get everything the way I want it, I group all objects so that they will behave like background objects visible on all (newly-added) cards. The problem is that after I group everything, if I click anywhere on the BACKGROUND (non-button/field area), it executes the script from the last button I added. It's as though the card has adopted the script of that last button. I am using LC Indy 8.1.4.

I am not sure if I am making sense but can someone help me? I am sure it's something stupid I am overlooking.

Thank you,
Jon

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Something strange...

Post by cmhjon » Mon Jun 12, 2017 9:12 pm

I got it figured out. For some reason the group was assuming the script of the last button.

Weird.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Something strange...

Post by dunbarx » Mon Jun 12, 2017 9:23 pm

Hi.
For some reason the group was assuming the script of the last button.
The group script will not, on its own, inherit the script of any child control. A "mouseUp" message, if not trapped, will pass from the target through the hierarchy of the message path.

If you are trapping a mouseUp message outside the extent of the group, that is, by clicking outside that group, there must be a handler in the card script or above.

So have you really figured it out? Write back. I am curious.

Craig Newman

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Something strange...

Post by cmhjon » Tue Jun 13, 2017 12:52 pm

Hi Craig,

Thank you for the reply. As best I can tell, the issue appears to be resolved. In the project browser, I remember seeing that the GROUP had 23 lines of code in it which is the same amount the last button I added has. Once I removed the script from the group, the issue went away. And yes, the buttons all have mouseUp. As I am somewhat new to LC, I still have a lot to learn (I got used to HyperCard and it's hierarchy back in the day).

Off the subject, how does one make custom dialog boxes in LC?

Thank you,
Jon

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Something strange...

Post by bogs » Tue Jun 13, 2017 2:24 pm

Fair example of making custom dialogs
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Something strange...

Post by dunbarx » Tue Jun 13, 2017 3:41 pm

And yes, the buttons all have mouseUp.
Do you mean the "phantom" mouseUp handlers that are pre-loaded withe every new button? Just as in HC, these are not compiled until you say so. I only mention this because the group script is normally the right place for such things, using the "target" to identify the button of interest. Just like HC might use the backGround script. They both have the card layer, of course.
(I got used to HyperCard and it's hierarchy back in the day).
The message hierarchy for LC is much the same as for HC. There is no background object class in LC, and there are no groups in HC. Otherwise you should be pretty comfortable.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Something strange...

Post by FourthWorld » Tue Jun 13, 2017 4:41 pm

dunbarx wrote:
(I got used to HyperCard and it's hierarchy back in the day).
The message hierarchy for LC is much the same as for HC. There is no background object class in LC, and there are no groups in HC.
In LC a group can be made compatible with HC by setting the backgroundBehavior property to true. Once set, new cards will include the background group, and the group will change its place in the message path to be after the card as HC does.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Something strange...

Post by dunbarx » Tue Jun 13, 2017 6:31 pm

What Richard said about backGround behavior. But the difference between HC and LC in this regard is profound, and unlearning takes a bit of practice.

The other main difference is how menus are managed. HC had "native" menu objects, whereas LC uses groups of buttons with certain group properties set. All just takes getting used to.

Craig

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Something strange...

Post by cmhjon » Tue Jun 13, 2017 8:28 pm

Hi all,

Thank you for your replies. This is good information!

One more question and I fear the answer but the stack I am building is an extremely simple one with a few buttons and text fields which will be compiled into a Windows app. The app is basically a simple database of employees and their skills. Each employee gets there own card. After compiling, I fill out one card, click a button to create a second card, and fill out that card. When I close and reopen the app, all the changes I made were not kept. How do I make the app keep my changes?

Thank you,
Jon :)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Something strange...

Post by bogs » Tue Jun 13, 2017 8:42 pm

OOh, ooh, let me see if I (finally) got this one !

All the 'cards' have to be on a separate stack, which is saved as a stack (not an executable). Then you have to call that stack from your main application stack, like this lesson shows.
Image

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Something strange...

Post by cmhjon » Wed Jun 14, 2017 9:15 pm

Hi bogs (and everyone else),

I got it working!!! Thank you! Changes are now saved! :)

I have everything working....except one thing. For some reason, after the app is built, one button does nothing when I click it. I have confirmed that a script is present and that it works in the native stack. It's noteworthy that when I build the app for Mac, the button works but not when it's built for Windows (which is where the app will be used). Here's the script of the button.

on mouseUp
ask "Please enter an employee name:"
put it into theEmployee
if theEmployee is empty then exit mouseUp
put number of cards into cardNumber
put number of this card into thisCard
lock screen
repeat for cardNumber
if fld "Employee Name" ≠ theEmployee then
go next
else
exit repeat
end if
end repeat
unlock screen
get number of this card
if it = thisCard then
answer "No employee found by that name."
end if
end mouseUp


Perhaps there's something in the above script that Windows doesn't like?

Any ideas?
Jon

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Something strange...

Post by Klaus » Wed Jun 14, 2017 9:50 pm

Hi Jon,

yep, this line is the culprit:
...
if fld "Employee Name" ≠ theEmployee then
...

This "not equal" character - is Mac-only so the script will fail on Windows at this line!
For cross-platform development use <> (smaller greater) for "not equal".


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Something strange...

Post by dunbarx » Thu Jun 15, 2017 12:50 am

And this is why it is so important to test standalones thoroughly. If the issue you saw here had occurred in the stack script, the whole program might have just failed, and there would be no indicaton of what went wrong. At least in the IDE, there are powerful tools that tell you where to look.

Craig

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Something strange...

Post by cmhjon » Thu Jun 15, 2017 12:42 pm

Klaus - yep, that fixed it! I should have known that. Even back in my HyperCard days, I always used the <> for not equal! :)

Craig - yes, I am aware of the importance of testing the standalone. While this particular app is extremely simple, it has been compiled several times to test each buttons functionality. With your and others help, I figure this app qualifies as beta now.

Thanks so much,
Jon :)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Something strange...

Post by bogs » Thu Jun 15, 2017 12:45 pm

Craig, I'm 100% with you on testing as rigorously as possible, but curious if something like this particular problem would have been caught in the IDEs tools?

In other words, lets say cmhjon develops on a mac, where the symbol Klaus points out is acceptable for use. The IDE will just run it and show no errors, wouldn't it? I ask, because I am far from an expert with the debugger in Lc, for all I know it may jump up and tell you so, or there may be some other tool that would do it ?

On the other side of this, though, that symbol does not exist in the Lc dictionary as far as I can tell, you may just want to limit your code to listed symbols, and if in doubt make sure to check the "Supported Operating Systems:" section until you are super proficient in what will and won't fly :)
LcSymbols.png
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”