Page 1 of 1
drag: bad end location expression
Posted: Thu Jun 20, 2013 2:20 pm
by garyth123
Hi,
I'm running preOpenCard from the message box and I'm getting
Script compile error:
Error description: drag: bad end location expression
My script, which is importing some XML and rendering it in a data grid a la tutorial 50, was working an iteration or so before I made some change (adding more fields to be displayed in the datagrid and a cLink).
I can't find the source of my error. Can anyone help me?
Thanks in advance.
Re: drag: bad end location expression
Posted: Thu Jun 20, 2013 2:37 pm
by Klaus
Hi garyth123,
well, we MIGHT need to look at the script to be able to help you...
Best
Klaus
Re: drag: bad end location expression
Posted: Thu Jun 20, 2013 2:53 pm
by garyth123
Basically I'm trying to render XML as a datagrid so that my script copies the tutorial Advanced XML Rendering using the Data Grid.
This function gets the XML and uses revXMLNodeContents to extract the data I'm interested in rendering:
function webService.GetAllTeams pApiKey
local tResult
local tDocID
local tResponse
local tParams
put empty into tParams
--surely needs SOAP.AddParam here
put SOAP.AddParam("ApiKey",pApiKey,"s:string","") after tParams
put SOAP.RPCRequest(,"GetAllTeams","",tParams,"") into tResult
if tResult is empty then
put SOAP.Response() into tResponse
put tidyXML(tResponse) into tResponse
put revCreateXMLTree(tResponse, false, true, false) into tDocID
put revXMLNumberOfChildren(tDocID,"/XMLSOCCER/","Team",-1) into theNumberOfChildren
repeat with myIndex = 1 to theNumberOfChildren
--put revXMLNodeContents(tDocID,"/XMLSOCCER/Team[" & myIndex & "]/Team_Id/") into theTeam_Id
put revXMLNodeContents(tDocID,"/XMLSOCCER/Team[" & myIndex & "]/Name/") into theName
put revXMLNodeContents(tDocID,"/XMLSOCCER/Team[" & myIndex & "]/Country/") into theCountry
put revXMLNodeContents(tDocID,"/XMLSOCCER/Team[" & myIndex & "]/Stadium/") into theStadium
put revXMLNodeContents(tDocID,"/XMLSOCCER/Team[" & myIndex & "]/HomePageURL/") into theHomePageURL
put revXMLNodeContents(tDocID,"/XMLSOCCER/Team[" & myIndex & "]/WIKILink/") into theWIKILink
--put theTeam_Id into theDataA[myIndex ]["Team_Id"]
put theName into theDataA[myIndex ]["Name"]
put theCountry into theDataA[myIndex ]["Country"]
put theStadium into theDataA[myIndex ]["Stadium"]
put theHomePageURL into theDataA [myIndex ]["HomePageURL"]
put theWIKILink into theDataA[myIndex ]["WIKILink"]
end repeat
end if
set the dgData of group "Datagrid 1" to theDataA
end webService.GetAllTeams
The next two function are from the datagrid behaviour script
on FillInData pDataArray
-- This message is sent when the Data Grid needs to populate
-- this template with the data from a record. pDataArray is an
-- an array containing the records data.
-- You do not need to resize any of your template's controls in
-- this message. All resizing should be handled in resizeControl.
-- Example:
--set the text of field "Team_Id" of me to pDataArray["Team_Id"]
set the text of field "Name" of me to pDataArray["Name"]
set the text of field "Country" of me to pDataArray["Country"]
set the text of field "Stadium" of me to pDataArray["Stadium"]
set the cLink of field "Name" of me to pDataArray["HomePageURL"]
end FillInData
on LayoutControl pControlRect
local theFieldRect
-- This message is sent when you should layout your template's controls.
-- This is where you resize the 'Background' graphic, resize fields and
-- position objects.
-- For fixed height data grid forms you can use items 1 through 4 of pControlRect as
-- boundaries for laying out your controls.
-- For variable height data grid forms you can use items 1 through 3 of pControlRect as
-- boundaries, expanding the height of your control as needed.
-- Example:
-- put the rect of field "Team_Id" of me into theFieldRect
-- put item 1 to 3 of pControlRect into item 1 to 3 of theFieldRect
-- put item 4 of pControlRect - 75 into item 4 of theFieldRect
-- set the rect of field "Team_Id" of me to theFieldRect
put the rect of field "Name" of me into theFieldRect
put item 4 of pControlRect - 75 into item 2 of theFieldRect
put item 3 to 4 of pControlRect into item 3 to 4 of theFieldRect
set the rect of field "Name" of me to theFieldRect
put the rect of field "Country" of me into theFieldRect
put item 1 to 3 of pControlRect into item 1 to 3 of theFieldRect
put item 4 of pControlRect - 75 into item 4 of theFieldRect
set the rect of field "Country" of me to theFieldRect
put the rect of field "Stadium" of me into theFieldRect
put item 4 of pControlRect - 75 into item 2 of theFieldRect
put item 3 to 4 of pControlRect into item 3 to 4 of theFieldRect
set the rect of field "Stadium" of me to theFieldRect
end LayoutControl
So really pretty much as per the tutorial. I did manage to render the Name of each team but when I included more of the data I got the error drag: bad end location. And it is a drag.
Re: drag: bad end location expression
Posted: Thu Jun 20, 2013 3:37 pm
by Klaus
Hi garyth,
hmm, this one is really puzzling me:
## drag: bad end location expression
since you do not have any DRAG or DRAGDROP or anything related in the scripts.
But wait, this is a standalone, right?
In that case all the Livecode libraries and externals, like XML support, have NOT YET been loaded "on preopenstack"!
Use "openstack" or "opencard" instead, that should do the trick.
Best
Klaus
Re: drag: bad end location expression
Posted: Thu Jun 20, 2013 3:46 pm
by garyth123
Hi Klaus,
I changed it to openCard and now the message box has the word 'form' in it. I don't think it is a problem with preOpenCard because as I say it was working previously. Also if I choose to make the datagrid a Table instead of a Form I can see my data in columns.
One other thing when I do choose Form for the datagrid, I can't get the Row Behaviour... script window to open.
Thanks very much with your help with this.
Gary
Re: drag: bad end location expression
Posted: Thu Jun 20, 2013 3:51 pm
by Klaus
Hi Gary,
hmmm, sorry, no brilliant idea in the moment...
Best
Klaus
Re: drag: bad end location expression
Posted: Fri Jun 21, 2013 5:12 pm
by garyth123
This has resolved itself now.
Re: drag: bad end location expression
Posted: Fri Jun 21, 2013 5:16 pm
by Klaus
What did you do, or not do?

Re: drag: bad end location expression
Posted: Fri Jun 21, 2013 5:20 pm
by garyth123
It's not clear to me what changed. However I have moved on to the next issue to arise ---
http://forums.runrev.com/phpBB2/viewtop ... =7&t=15651