Error trying to run a script on another card

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

Post Reply
cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

Error trying to run a script on another card

Post by cbarbal » Mon Nov 05, 2018 11:33 am

Hi all,

In a data grid, from the "Finques" card, I have a script that selects the data from a row and passes it to another data grid, from the "Pisos" card, and I also want to execute a script, "Pisos" card, which fills the individual fields.

Everything works perfectly until you get to the script that you have to fill in the individual fields that gives me error. It could be because the initial script tries to execute the script of another card. I attach the two scripts and the error

Code: Select all

on mouseUp
   -- CARD FINQUES
   local tLine, tID
   put the dgHilitedLines of group "Pisos" into tLine
   put the dgDataOfLine[tLine] of group "Pisos" into tDataLine
   put tDataLine["COL 1"] into tID
   put "SELECT p.pisID, f.finca ||' '|| p.pis, p.lloguer FROM Pisos p, Finques f WHERE p.FincaID = f.fincaID AND p.PisID = '" & tID & "'" into tQuery
   put textDecode(revDataFromQuery(tab, cr, gDatabaseID, tQuery),"UTF-8") into tData
   
   -- CARD PISOS
   go card "Pisos"
   set the dgText of group "dgPisos" to tData
   
   -- ERROR
   showRecordPisos2
end mouseUp
group "Pisos": execution error at line 15 (Handler: can't find handler) near "showRecordPisos2", char 1

Code: Select all

on showRecordPisos2
    tFields
   
   put the dgDataOfLine[1] of group "dgPisos" into tFields
   
   put tFields["Col 1"] into  field "ID"
   put tFields["Col 3"] into  field "Lloguer"
   put displayFormat(field "Lloguer") into field "Lloguer"
   
   put "SELECT p.Referencia, p.Pis, p.Rebut, f.Finca, p.FincaID FROM Pisos p, Finques f WHERE pisID='" & field "ID" & "'" & " AND p.fincaID = f.fincaID"  into tQuery
   put textDecode(revDataFromQuery(tab, cr, gDatabaseID, tQuery),"UTF-8") into tData
   
   set the itemDelimiter to tab
   put item 1 of tData into field "Referencia"
   put item 2 of tData into field "Pis"
   
   if item 3 of tData = 1 then
      set the hilite btn "btnRebut" to true
   else
      set the hilite btn "btnRebut" to false
   end if
   
   put item 4 of tData into field "Finca"
   
   set text of field "lblSelect" to field "finca" && field "pis"
   showLloguers
   --   showTotalsPisos
end showRecordPisos2
f so, is there a way to do it? PreOpenCard does not work for me. Another thing the script that fails is associated with a data grid in the "Pisos" card

Another thing. I think it's called hard return, which allows you to separate a very long line in several lines "\". Some idea to do it with the keyboard of a MacBook.

I hope to have explained myself well, Thanks in advance

Carles

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

Re: Error trying to run a script on another card

Post by Klaus » Mon Nov 05, 2018 12:24 pm

Hi Calres,

is the handler "showRecordPisos2" really in the card script of card "Pisos"?
If yes, you could try:
...
## showRecordPisos2
send "showRecordPisos2" to cd "Pisos"
...
If not, well then the error is no surprise! 8)

Some hints:
1. The second line in handler "showRecordPisos2" reads -> tFields
Mistake or typo?

2. Don get used to sloppy scripting, that may bite you one day! :D
This:
## set the hilite btn "btnRebut" to true
## Should read:
set the hilite OF btn "btnRebut" to true

3. On my german keyboard, the backslash \ is created by SHIFT-ALT-7.

4. And for continuity's sake, you can use OF throughout:
-> the label OF btn "my button" OF grp "a group" OF cd "your card" OF stack "a substack" OF stack "another stack".


Best

Klaus

cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

Re: Error trying to run a script on another card

Post by cbarbal » Mon Nov 05, 2018 3:21 pm

Danke Klaus,

send "showRecordPisos2" to cd "Pisos" is O.K.

Hint:
1. local tFields

2. "ON" I usually put it

3. I have not expressed myself well, my keyboard also appears the backslash \ . I mean the following:

Code: Select all

put "SELECT p.Referencia, p.Pis, p.Rebut, f.finca, p.FincaID FROM Pisos  p, Finques f \
   WHERE pisID='" & field "ID" & "'" & " AND p.FincaID = f.fincaID"  into tQuery
and that I'm not error to separate the line in two

4. Normally in the demos and the lessons the path is not seen in such detail.

I have some doubts of concept, I will put them in a new post. But first I have to translate it with Google and then polish it so that it is understood.

Regqards,

Carles

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

Re: Error trying to run a script on another card

Post by Klaus » Mon Nov 05, 2018 4:02 pm

Hi Carles,

OK, but you cannot separate a STRING like this with the backslash, unless you do:

Code: Select all

put "SELECT p.Referencia, p.Pis, p.Rebut, f.finca, p.FincaID FROM Pisos  p, Finques f" && \
   "WHERE pisID='" & field "ID" & "'" & " AND p.FincaID = f.fincaID"  into tQuery
Best

Klaus

cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

Re: Error trying to run a script on another card

Post by cbarbal » Mon Nov 05, 2018 4:14 pm

Danke Klaus,

Thanks for the clarification.

Regards,

Carles

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”