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
-
tusa
- Posts: 36
- Joined: Sun Jan 31, 2016 10:30 pm
Post
by tusa » Wed Oct 25, 2017 5:15 am
Hello.
Right now i'm able to send a command to a socket and I recieve this:
Code: Select all
201 INFO TEMPLATE OK
<?xml version="1.0" encoding="utf-8"?>
<template version="2.0.0" authorName="Tue Sandbæk" authorEmail="tue@broadcastsupport.dk" templateInfo="TV SYD, KV17 credit" originalWidth="1920" originalHeight="1080" originalFrameRate="50">
<components>
<component name="CasparTextField">
<property name="text" type="string" info="String data"/>
</component>
</components>
<keyframes/>
<instances>
<instance name="f1" type="CasparTextField"/>
<instance name="f0" type="CasparTextField"/>
</instances>
<parameters/>
</template>
I need to search for the number of instance name and regarding on the number of intances I want to show (in this example 2) rows in a datagrid, that I can fill in with data.
Brg Tue.
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Wed Oct 25, 2017 11:20 am
Hi Tusa,
here my easy-peasy solution without regex:
Code: Select all
on mouseUp
## I put your XML into field 1 of my little test stack
put fld 1 into tData
filter lines of tData with "*<instance name=*"
put the num of lines of tData
end mouseUp
and it reported 2 as exspected.
Best
Klaus
-
tusa
- Posts: 36
- Joined: Sun Jan 31, 2016 10:30 pm
Post
by tusa » Thu Oct 26, 2017 7:01 am
With that piece of code I now managed to get the two lines:
Code: Select all
<instance name="f1" type="CasparTextField"/>
<instance name="f0" type="CasparTextField"/>
inside a field, but i need pass the "f0" and "f1" on two lines in a datagrid.
So I guess I have to extract only what's inside the instance name="" into something?
-
Thierry
- VIP Livecode Opensource Backer

- Posts: 875
- Joined: Wed Nov 22, 2006 3:42 pm
Post
by Thierry » Thu Oct 26, 2017 7:51 am
tusa wrote: ↑Thu Oct 26, 2017 7:01 am
but i need pass the "f0" and "f1" on two lines in a datagrid.
So I guess I have to extract only what's inside the instance name="" into something?
Try this code in a button:
Code: Select all
on mouseup
local tData, R
put line -16 to -2 of the script of me into tData
filter lines of tData with regex pattern "<instance name="
repeat for each line L in tData
if matchText( L, "\sname=.(.+?).\s", aNameValue) then
-- do whatever you like with aNameValue -> f0, f1,...
put "found: " & aNameValue &cr after R
end if
end repeat
put R
end mouseUp
/*
201 INFO TEMPLATE OK
<?xml version="1.0" encoding="utf-8"?>
<template version="2.0.0" authorName="Tue Sandbæk" authorEmail="tue@broadcastsupport.dk" templateInfo="TV SYD, KV17 credit" originalWidth="1920" originalHeight="1080" originalFrameRate="50">
<components>
<component name="CasparTextField">
<property name="text" type="string" info="String data"/>
</component>
</components>
<keyframes/>
<instances>
<instance name="f1" type="CasparTextField"/>
<instance name="f0" type="CasparTextField"/>
</instances>
<parameters/>
</template>
*/
There is, as often with LC, few ways to love a cat...
Hopefully, someone will come using offset (check in the dictionary)
HTH,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Thu Oct 26, 2017 10:26 am
Oh, sorry, I missed the "name" part...