Action Script / Relevance question

I’m having action script that reads output from file and trying to use “tuple” statement to return individual values

there are some instances where output does not always contain all the subitems
i want to know how I can check this and if file is not having the right items replace this with N/A or something similar.

parameter “_IPInfo” = “155.119.213.66;155.119.0.0;255.255.0.0;EU - BELGIUM1 - BELGIUM2 - 0257”

parameter "_Value0" = "{tuple string item 0 of (concatenation ", " of (substrings separated by " - " of tuple string item 3 of (concatenation ", " of (substrings separated by ";" of (parameter "_IPInfo")))))}"
parameter "_Value1" = "{tuple string item 1 of (concatenation ", " of (substrings separated by " - " of tuple string item 3 of (concatenation ", " of (substrings separated by ";" of (parameter "_IPInfo")))))}"
parameter "_Value2" = "{tuple string item 2 of (concatenation ", " of (substrings separated by " - " of tuple string item 3 of (concatenation ", " of (substrings separated by ";" of (parameter "_IPInfo")))))}"
parameter "_Value3" = "{tuple string item 3 of (concatenation ", " of (substrings separated by " - " of tuple string item 3 of (concatenation ", " of (substrings separated by ";" of (parameter "_IPInfo")))))}"
parameter "_Value4" = "{tuple string item 4 of (concatenation ", " of (substrings separated by " - " of tuple string item 3 of (concatenation ", " of (substrings separated by ";" of (parameter "_IPInfo")))))}"

below is the output and it failed on last statement as that item did not exist

Command succeeded parameter “_IPInfo” = "155.119.213.66;155.119.0.0;255.255.0.0;EU - BELGIUM1 - BELGIUM2 - 0257"
Command succeeded parameter “_Value0” = "EU"
Command succeeded parameter “_Value1” = "BELGIUM1"
Command succeeded parameter “_Value2” = "BELGIUM2"
Command succeeded parameter “_Value3” = "0257"
Command failed (Relevance substitution failed) parameter “_Value4” = "{tuple string item 4 of (concatenation ", " of (substrings separated by " - " of tuple string item 3 of (concatenation ", " of (substrings separated by “;” of (parameter “_IPInfo”)))))}"
Command failed (Relevance clauses must be surrounded by { and } guards.) parameter “_Value4” = "{tuple string item 4 of (concatenation ", " of (substrings separated by " - " of tuple string item 3 of (concatenation “, " of (substrings separated by “;” of (parameter “_IPInfo”)))))}”

Thx

Often we can trap an error like that using the pipe operator '|'
The basic syntax is
(some problematic expression) | ( value to return on error)
The left and right sides of the pipe must return the same type, so we may need to cast 'as string’s on the left as well.

Try
parameter "_Value4" = "{(tuple string item 4 of (concatenation ", " of (substrings separated by " - " of tuple string item 3 of (concatenation “, " of (substrings separated by ";" of (parameter "_IPInfo"))))) as string) | "N/A"}"

1 Like

Jason,
thx for the help that did the trick, appreciate quick response.

Denis

2 Likes