Something stopping code working

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

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Something stopping code working

Post by CAsba » Fri Jan 06, 2023 12:18 pm

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 ?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9458
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Something stopping code working

Post by richmond62 » Fri Jan 06, 2023 1:12 pm

Personally I would always write

Code: Select all

send "mouseUp"

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: Something stopping code working

Post by CAsba » Fri Jan 06, 2023 1:27 pm

Thanks. I tried following your suggestion, but no change.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9458
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Something stopping code working

Post by richmond62 » Fri Jan 06, 2023 1:30 pm

Is your button called "button01"?
-
Screen Shot 2023-01-06 at 2.30.05 pm.png
Screen Shot 2023-01-06 at 2.30.05 pm.png (5.43 KiB) Viewed 2473 times

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: Something stopping code working

Post by CAsba » Fri Jan 06, 2023 1:45 pm

Hi. No, it's called button10.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9458
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Something stopping code working

Post by richmond62 » Fri Jan 06, 2023 2:00 pm

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.
Attachments
Call Me.livecode.zip
Stack.
(917 Bytes) Downloaded 66 times

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

Re: Something stopping code working

Post by Klaus » Fri Jan 06, 2023 3:02 pm

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.

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

Re: Something stopping code working

Post by dunbarx » Fri Jan 06, 2023 3:04 pm

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

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

Re: Something stopping code working

Post by Klaus » Fri Jan 06, 2023 3:10 pm

In that case the "no such object" error would (should) have been displayed.

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: Something stopping code working

Post by CAsba » Fri Jan 06, 2023 4:22 pm

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.

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

Re: Something stopping code working

Post by dunbarx » Fri Jan 06, 2023 4:53 pm

Hmmph.

Never happened to me. 8)

Craig

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

Re: Something stopping code working

Post by Klaus » Fri Jan 06, 2023 4:55 pm

HA! Very good one, Craig! :D

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

Re: Something stopping code working

Post by Klaus » Fri Jan 06, 2023 6:29 pm

OK, I confess I even created a bug report once out of my blindness. :D

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Something stopping code working

Post by mwieder » Sat Jan 07, 2023 3:15 am

What, just once?
Good thing nobody sees my embarrassing history.

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

Re: Something stopping code working

Post by Klaus » Sat Jan 07, 2023 3:31 pm

We are all ears, Mark! :-D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”