Page 1 of 2

Something strange...

Posted: Mon Jun 12, 2017 8:17 pm
by cmhjon
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

Re: Something strange...

Posted: Mon Jun 12, 2017 9:12 pm
by cmhjon
I got it figured out. For some reason the group was assuming the script of the last button.

Weird.

Re: Something strange...

Posted: Mon Jun 12, 2017 9:23 pm
by dunbarx
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

Re: Something strange...

Posted: Tue Jun 13, 2017 12:52 pm
by cmhjon
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

Re: Something strange...

Posted: Tue Jun 13, 2017 2:24 pm
by bogs
Fair example of making custom dialogs

Re: Something strange...

Posted: Tue Jun 13, 2017 3:41 pm
by dunbarx
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

Re: Something strange...

Posted: Tue Jun 13, 2017 4:41 pm
by FourthWorld
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.

Re: Something strange...

Posted: Tue Jun 13, 2017 6:31 pm
by dunbarx
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

Re: Something strange...

Posted: Tue Jun 13, 2017 8:28 pm
by cmhjon
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 :)

Re: Something strange...

Posted: Tue Jun 13, 2017 8:42 pm
by bogs
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.

Re: Something strange...

Posted: Wed Jun 14, 2017 9:15 pm
by cmhjon
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

Re: Something strange...

Posted: Wed Jun 14, 2017 9:50 pm
by Klaus
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

Re: Something strange...

Posted: Thu Jun 15, 2017 12:50 am
by dunbarx
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

Re: Something strange...

Posted: Thu Jun 15, 2017 12:42 pm
by cmhjon
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 :)

Re: Something strange...

Posted: Thu Jun 15, 2017 12:45 pm
by bogs
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