Page 1 of 2
Something stopping code working
Posted: Fri Jan 06, 2023 12:18 pm
by CAsba
Hi,
The user may navigate through a series of cards by 'back' and 'next' buttons. As well as directing the user to the next card, the button also sets the location of the 'back' and 'next' buttons on the next card. The code for setting the locations is
Code: Select all
set the loc of btn "Back" to "365,625"
set the loc of btn "Next.." to "645,625"
. This works fine on a succession of cards, except for a particular card, similar but not identical to the other cards, where the locations of the 'back' and 'next' are not moved to their correct locations. I also tried send mouseup to a button on the next card to position the buttons but that does not work, even though the button works when clicked on.
Code: Select all
send mouseup to btn "button10" of cd "business contact details"
This anomaly only occurs on the card 'business contact details'.
I checked the Inspector of the card but could not find any setting that would influence this (as far as I know).
Any ideas, please ?
Re: Something stopping code working
Posted: Fri Jan 06, 2023 1:12 pm
by richmond62
Personally I would always write
Re: Something stopping code working
Posted: Fri Jan 06, 2023 1:27 pm
by CAsba
Thanks. I tried following your suggestion, but no change.
Re: Something stopping code working
Posted: Fri Jan 06, 2023 1:30 pm
by richmond62
Is your button called "button01"?
-

- Screen Shot 2023-01-06 at 2.30.05 pm.png (5.43 KiB) Viewed 3976 times
Re: Something stopping code working
Posted: Fri Jan 06, 2023 1:45 pm
by CAsba
Hi. No, it's called button10.
Re: Something stopping code working
Posted: Fri Jan 06, 2023 2:00 pm
by richmond62
Please try this stack.
Code: Select all
on mouseUp
send "mouseUp" to btn "button10" of cd "K2"
end mouseUp
THEN check:
1. The card name.
2. The button name.
In your stack.
Re: Something stopping code working
Posted: Fri Jan 06, 2023 3:02 pm
by Klaus
Some hints:
1. Numbers (like the LOC of an object) do not need QUOTES around them.
2. What does "the result" say right after unsuccessful "sending" mouseup to that namely button
which works when actually clicked with the mouse? That may give you a hint.
Code: Select all
...
send "mouseup" to btn xyz of cd zyx
answer the result
...
3. Instead of sending "mouseup" to far away objects, OUTSOURCE the command(s) to the stack- or cardscript and just call it from anywhere. Same for everything that is called more than once.
Example:
Code: Select all
on mouseup
set_button_locs
end mouseup
In the stackscript:
Code: Select all
command set_button_locs
set the loc of btn "Back" OF CD "whatever" to 365,625
set the loc of btn "Next.." OF CD "whatever" to 645,625
## ...
end set_button_locs
This way you can make sure that every object will be found and does the right thing, know what I mean?#
Will also prevent you from the "no such object" error, if the object is not on the current card.
Re: Something stopping code working
Posted: Fri Jan 06, 2023 3:04 pm
by dunbarx
CAsba.
I have not seen Richmond's stack, but are you sure you named the button "button10" and not "button 10"?
Big difference if there is a space in there.
Craig
Re: Something stopping code working
Posted: Fri Jan 06, 2023 3:10 pm
by Klaus
In that case the "no such object" error would (should) have been displayed.
Re: Something stopping code working
Posted: Fri Jan 06, 2023 4:22 pm
by CAsba
I have to apologise, the error was of my own making..The instruction was subject to a series of if staements that I got into a muddle with, without realizing it. I'm so sorry to waste your time.
Re: Something stopping code working
Posted: Fri Jan 06, 2023 4:53 pm
by dunbarx
Hmmph.
Never happened to me.
Craig
Re: Something stopping code working
Posted: Fri Jan 06, 2023 4:55 pm
by Klaus
HA! Very good one, Craig!

Re: Something stopping code working
Posted: Fri Jan 06, 2023 6:29 pm
by Klaus
OK, I confess I even created a bug report once out of my blindness.

Re: Something stopping code working
Posted: Sat Jan 07, 2023 3:15 am
by mwieder
What, just once?
Good thing nobody sees my embarrassing history.
Re: Something stopping code working
Posted: Sat Jan 07, 2023 3:31 pm
by Klaus
We are all ears, Mark!
