Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Objective: To pass in variable into substitute command. ex: execute("substitute 'src'dst'")
Problem: Arbortext $ERROR says its parsing error claiming a missing variable. However testing response($outputVariable) provides the expected value output to the screen. Leading to confusion on why I can see I have the correct value, and the substitute functions works when using a dummy hardcoded string value, but not when passing in a value retrieved from a dictionary I created using another text file.
The Process:
I have two files.
1 text file & 1 xml file.
open text file
create an associative array (dictionary) from the key/value pairs in the text file.
close text file
>>> key/value access is successful. response($outputVariable) function displays expected value.
open xml file
perform substitution
close xml file
>>> If i place a dummy s tring value like a word "testing" then the substitution works flawlessly
>>> If i pass in the variable $outputValue captured from the dictionary the substitution fails.
>>>> $ERROR returns
"Error parsing command String: substitute <openingTag></closingTag ' <openingTag> expected output value ..." (the expected output value is truncated with an ellipses (...)
then states "Starting at command: </closingTag>' [A11320] missing argument."
It's strange because $outputValue is pointing to the right value.
> the error message hints at substitute containing the desired value and executing correctly but instead fails.
> the error message says "missing argument" but I pass in an input text and a replacement text and my $outputValue variable contains the correct value.
$outputValue = $outputValueDictionary["key"]
$substituteCommand = "substitute -a -noe -ws '<openingTag></closingTag>'" . "<openingTag> $outputValue </closingTag>" . "'"
response($outputValue)
if (execute($substituteCommand) != 0) {
response($ERROR)
}
Solved! Go to Solution.
In the attachment you can find the following documents for the 7.1 release:
What version of Arbortext are you using?
versions limited to whats approved for work so:
Currently using Epic Editor V6.1
In the next couple months we should be updating to V7.1
I keep thinking it has to do with the order of code compilation since it doesnt feel like its performing it sequentially line by (ACL commands vs functions thinking) But really I still can't grasp what could possibly be occurring.
In the attachment you can find the following documents for the 7.1 release:
Would there have been this issue resolved in a later version? Im curious if this was actually a bug because there doesn't seem to be an approach I can take that works using the two files in a script.
I think you have the wrong syntax for the substitute command. It is expecting a "/" character as the separator.
"substitute [ -b | -f] [ -c | -noc] [ -a] [ -e | -noe] [ -wrapscan | -nowrapscan] [ -q | -noq] [ -markup] /oldtext/newtext/"