Search Error Message

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
kespears
Posts: 12
Joined: Sat Aug 04, 2018 2:07 pm

Search Error Message

Post by kespears » Sun Aug 12, 2018 8:37 pm

I'm finishing a Card Database and I added a Search button with the following code:

on mouseUp
go to stack "Search" as palette
end mouseUp

When I press the Search button I get the following error:
Search LiveCode Error.png
The action stops here:

on openCard
put the number of this card && "of" && the number of cards of this stack into field "page"
end openCard

I appreciate any suggestions.

quailcreek
Posts: 729
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: Search Error Message

Post by quailcreek » Sun Aug 12, 2018 9:38 pm

Is stack "Search" a substack?
Where is your openCard script located?
Tom
MacBook Pro OS Mojave 10.14

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

Re: Search Error Message

Post by bogs » Sun Aug 12, 2018 9:51 pm

Yah, was going to say that code has a bit of a logic error maybe.

The way it looks (to me) is like you click on the search button, go to a separate stack named search, and when the card on that stack opens, your telling it to put the number of the card of the search stack "of" the cards of the search stack (I would assume there is only one card there for one thing, and the cards you actually want are in the main application stack).

What you would actually need/want is the number of the card you came from out of the number of cards in the main stack, I'm guessing.

If I am correct in that assumption, you could do something like this -

Code: Select all

// button code ...
on mouseUp
   set the cpropTarget of this stack to the number of this card
   go to stack "search" as palette
end mouseUp
Search stack open card code -

Code: Select all

on openCard
   put the cpropTarget of stack "frmMain" && "of" && the number of cards of stack "frmMain" into field "page"
end openCard
*Edit - this also assumes of course that you have a field on your search stack card that is named "page". If not, that is the object error.

*Edit 2 - maybe not, char 43 is "number'. hm.
Image

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

Re: Search Error Message

Post by FourthWorld » Sun Aug 12, 2018 11:40 pm

Is field "page" in the palette or the topstack?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

kespears
Posts: 12
Joined: Sat Aug 04, 2018 2:07 pm

Re: Search Error Message

Post by kespears » Mon Aug 13, 2018 2:43 am

quailcreek, the “Search” is a button in the Main.Stack. Thanks.

bogs, The “openCard.....Pages” is in a field in the Main.stack as well. Its only function is to shop Page# of Pages. I will update my Scripts with your suggestions and give it a try. Thanks.

FourthWorld, the “page” is on the Main.Stack. Thanks

Keith

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

Re: Search Error Message

Post by bogs » Mon Aug 13, 2018 3:45 am

Hm. I don't think my script is going to help you overly much then, as I said, after reading your post I assumed that the field "page" was only on the search stack. It would certainly make more sense to have it on every card of the main stack, as I am guessing thats where the cards your cycling through are.

If that is the case, it would certainly be easier to just put an empty openCard handler on the search stack card and eliminate the field "page" from that stack setup altogether. That eliminates using the custom property I setup and reduces your code back to what it was.

*Edit - I found the program lesson your following, I'll take a look at it so that I might better help you out.

*Edit 2 - Ok, so if I'm right, this is a picture of what the app your working on looks like -
Image
Is that the app?
Image

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

Re: Search Error Message

Post by bogs » Mon Aug 13, 2018 5:05 am

Actually it is much like I thought after I found (I think) the app article kespears is following.
You can make an app! wrote: Finally, go to the stack script for the Search stack and add an "on openCard" handler. It doesn’t need anything inside – this is just to stop our openCard script from the main stack from being run when this stack’s card opens.
So, I was right above - the field "page" isn't on the search stack (object error char 43), and from the last post -
bogs wrote:
Mon Aug 13, 2018 3:45 am
If that is the case, it would certainly be easier to just put an empty openCard handler on the search stack card and eliminate the field "page" from that stack setup altogether.
The article wasn't a bad one, you come out with a very simple but highly functional starting program, although it did contain mistakes (mainly the missing "go" when switching cards, but the article also said to drag an image object out and then never used it !? I of course used it for a backdrop :twisted: ).

Lc is easy, but proof reading a bit more when writing things is good too. Of course, an argument could be made that "... we need to find out what the level of problem solving skills are...", but myself, I just find that agravating when it is pulled on me.
Image

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

Re: Search Error Message

Post by FourthWorld » Mon Aug 13, 2018 6:28 am

bogs wrote:
Mon Aug 13, 2018 3:45 am
...it would certainly be easier to just put an empty openCard handler on the search stack card and eliminate the field "page" from that stack setup altogether.
Or move the code to the shared group. Either option will work well without needing to add extra stuff.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: Search Error Message

Post by bogs » Mon Aug 13, 2018 7:45 am

Yep, like most beginner tutorials, it left room for lots of improvements and ways to do things as your skills grow.

The article looks like it was geared towards getting the most bang for the buck from the simplest amount of code, but I could certainly see sticking the page numbering thing any number of other less likely to foul up places, such as the group you mention.
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4702
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Search Error Message

Post by jacque » Mon Aug 13, 2018 5:49 pm

Palettes didn't used to gain focus unless you clicked on them, so the original lesson probably worked when it was written. I'm not sure if the new behavior is intentional or a bug. (I didn't actually try to test it.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Search Error Message

Post by FourthWorld » Mon Aug 13, 2018 6:16 pm

If a field is open for editing, such as the Search field in this palette, the palette would have focus.

To shift focus to another stack for subsequent commands set the defaultStack global property to that stack.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: Search Error Message

Post by bogs » Mon Aug 13, 2018 7:24 pm

jacque wrote:
Mon Aug 13, 2018 5:49 pm
Palettes didn't used to gain focus unless you clicked on them, so the original lesson probably worked when it was written.
If I was looking at the right lesson that kespears was following, then we are talking about 2014. The Lc in the picture I am guessing is 6.x series, and they talk about Lc being open source, so I am putting it around 6.5.
Image

kespears
Posts: 12
Joined: Sat Aug 04, 2018 2:07 pm

Re: Search Error Message

Post by kespears » Tue Aug 14, 2018 10:48 pm

Bogs, your are correct regarding the 2014 article that I was following.

Thanks to you and FourthWorld and other for your response and direction. Great information. I will try to finish it this evening after visiting my sons school. Schools in on LC and in my neighborhood.

Thanks
Keith

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

Re: Search Error Message

Post by bogs » Wed Aug 15, 2018 1:35 am

Glad we could help Keith :D
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”