¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Extracting part of a return string


 

Hi,

I was wondering what the best way in SIMPL was to extract part of a return string to enable another digital signal.?


for example:?
my return varies between states like below: I need to extract; say the ¡®recording¡¯: {¡®state¡¯: ¡®running¡¯ part of the string and that enables a Recording message on my touch panel?
?Preview is state running (Recording is state idle also live)


state={'profile': 'signal-test', 'preview': {'state': 'running', 'status_message': 'Preview is running', 'hls_playlist': '/static/hls/7abb/adaptive.m3u8'}, 'recording': {'state': 'idle', 'status_message': 'Ready to record'}, 'live': {'available': True, 'linked_to_recording': False, 'state': 'idle', 'status_message': 'Ready to start'}, 'paused': False, 'video': [{'type': 'vtestsource', 'name': 'vsource-4c68', 'device': 'blue', 'capture': '1920x1080@25', 'signal': 'fake', 'state': 'running'}, {'type': 'vtestsource', 'name': 'vsource-af64', 'device': 'green', 'capture': '1280x720@25', 'signal': 'fake', 'state': 'running'}]}


- Recording is state running and live is state idle

state={'profile': 'signal-test', 'preview': {'state': 'running', 'status_message': 'Preview is running', 'hls_playlist': '/static/hls/7abb/adaptive.m3u8'}, 'recording': {'state': 'running', 'status_message': 'Recording in progress', 'folder': '/home/ubicast/mediacoder/media/20220208-181139-0d80', 'time_in_sec': 8, 'timecode': '0:00:08'}, 'live': {'available': True, 'linked_to_recording': False, 'state': 'idle', 'status_message': 'Ready to start'}, 'paused': False, 'video': [{'type': 'vtestsource', 'name': 'vsource-4c68', 'device': 'blue', 'capture': '1920x1080@25', 'signal': 'fake', 'state': 'running'}, {'type': 'vtestsource', 'name': 'vsource-af64', 'device': 'green', 'capture': '1280x720@25', 'signal': 'fake', 'state': 'running'}]}


- Live is state running and recording is state idle

state={'profile': 'signal-test', 'preview': {'state': 'running', 'status_message': 'Preview is running', 'hls_playlist': '/static/hls/7abb/adaptive.m3u8'}, 'recording': {'state': 'idle', 'status_message': 'Ready to record'}, 'live': {'available': True, 'linked_to_recording': False, 'state': 'running', 'status_message': 'On Air'}, 'paused': False, 'video': [{'type': 'vtestsource', 'name': 'vsource-4c68', 'device': 'blue', 'capture': '1920x1080@25', 'signal': 'fake', 'state': 'running'}, {'type': 'vtestsource', 'name': 'vsource-af64', 'device': 'green', 'capture': '1280x720@25', 'signal': 'fake', 'state': 'running'}]}


 

There are ways to extract and match strings in SIMPL, especially if they are fixed length or if there is a fixed pattern, which your strings appear to have.
However, the string example you present appear to be too long to handle in SIMPL.
Therefore, you will need to use S+, and doing so will make the job a lot easier.

Lindsay


 

¿ªÔÆÌåÓý

If the OP were trying to process the entire string or if there was more variability in the strings I would agree but it seems for what they want/need it could be done in an SIO, for example:

?

Parameter 1

'recording': {'state': 'idle',

?

Parameter 2

'recording': {'state': 'running',

?

Then take those to a IL (or an INIT/EQU combo) to latch the recording status.

?

Parameter 3

'live': {'available': True, 'linked_to_recording': False, 'state': 'idle',

?

Parameter 4

'live': {'available': True, 'linked_to_recording': False, 'state': 'running',

?

Then take those to an IL (or an INIT/EQU combo) to latch the live status

?

If you need a ¡°recording and not live¡± ¡°live and not recoding¡± ¡°live and recording¡± FB you could either use a collection of gates or a TT to yield that result.

?

Of course this would be real easy and the most robust/error resistant in S# where you can just deserialize the JSON into an object

?

--

Lincoln King-Cliby, CTS, DMC-E-4K/T/D
Commercial Market Director
Sr. Systems Architect | Crestron Certified Master Programmer (Diamond)
ControlWorks Consulting, LLC
Direct: (+1)440.771.4807 | Cleveland: (+1)440.449.1100? | Boston: (+1)508.695.0188 | DC: (+1)202.381.9070? | Fax: (+1)440.449.1106
Crestron Services Provider | Biamp Authorized Independent Programmers | Extron Qualified Independent Programmer

?

From: [email protected] [mailto:[email protected]] On Behalf Of l_codd
Sent: Thursday, February 10, 2022 4:58 AM
To: [email protected]
Subject: Re: [crestron] Extracting part of a return string

?

There are ways to extract and match strings in SIMPL, especially if they are fixed length or if there is a fixed pattern, which your strings appear to have.
However, the string example you present appear to be too long to handle in SIMPL.
Therefore, you will need to use S+, and doing so will make the job a lot easier.

Lindsay


 

Hi,

Lincoln that worked for me...

Thank you so much for your help, i really appreciate it.?

I thought I would have needed Substrings and Gathers to pull the information but your suggestion has worked a charm.

Have a great day