I have tried several python scripts.
The %PythonScriptOutput% is of type text.
I want to make it a number type, but Convert text to number doesn't work.
Does anyone have a solution?
SET List TO [155, 168, 5456, 551, 156, 599, 256, 636, 266, 4894, 282, 522, 266]
Text.JoinWithCustomDelimiter List: List CustomDelimiter: $''',''' Result=> JoinedText
System.RunPythonScript PythonCode: $'''listb = [%JoinedText%]
print max(listb)''' ScriptOutput=> PythonScriptOutput ScriptError=> ScriptError
Display.ShowMessage Title: $'''PAD''' Message: $'''%PythonScriptOutput%
%ScriptError%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed
Text.ToNumber Text: PythonScriptOutput Number=> TextAsNumber
I went into a little more detail.
Assigning a value to PythonScriptOut using print outputs a newline code.
So I used "sys.stdout.write" in python scrip to avoid outputting the newline code.
However, I still couldn't convert it to a number.
import sys
listb = [%JoinedText%].
m=max(listb)
sys.stdout.write(str(m))
In the end, I decided to use regular expressions to extract the numbers.
This is not a smart way.
SET List TO [155, 168, 5456, 551, 156, 599, 256, 636, 266, 4894, 282, 522, 266]
Text.JoinWithCustomDelimiter List: List CustomDelimiter: $''',''' Result=> JoinedText
System.RunPythonScript PythonCode: $'''import sys
listb = [%JoinedText%]
m=max(listb)
sys.stdout.write(str(m))''' ScriptOutput=> PythonScriptOutput ScriptError=> ScriptError
Text.RegexParseForFirstOccurrence Text: PythonScriptOutput TextToFind: $'''[0-9]+''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position Match=> Match
Text.ToNumber Text: Match Number=> TextAsNumber
Between the PAD and the Run python script action, I don't think this is a smart way to input/output values.
Does anyone know of a better way?
Try converting %PythonScriptOutput.Trimmed% since it looks like there is a new line after the text.
Hi Henrik_M
Thank you for your reply.
I tried %PythonScriptOutput.Trimmed%.
But it did not work.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Did you know that you could restore a deleted flow? Check out this helpful article.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
19 | |
7 | |
5 | |
3 | |
2 |