Reformat text string

Benjamin Solem

Posted on 23.03.2022 13:04

Hi,


Is there a way to reformat a text string in the sequencer or with help of calculations in a setup?


I have an input to a sequence variable from a form always looking like "123456789" which I really want to format as 123.4567-89.


I cannot find any way to extract the first/last x digits or characters from this string to rework the format. Is there a way to do this?


BR,

Benjamin

Gregor Šmit

Posted on 24.03.2022 15:22

Dear Benjamin,


thank you for contacting us. There is no option in the sequencer to reformat the input text from "123456789" to 123.4567-89. You could use the python script or a bat file to reformat the string. We have a solution where a bat file is run from the sequencer. In the attachment is a screenshot of a File manager block which runs a python script with input parameter. The output from a python script is assigned to a sequencer variable using the python command exit(output_variable).


Kind regards.


Attached files:
Benjamin Solem

Posted on 08.04.2022 09:05

That's unfortunate, however, thanks for the reply.


Benjamin

Gary Floyd

Posted on 07.08.2022 05:35

@Gregor Šmit Does the python example actually work, just tried it with text, integers, and floats. The windows command line and vscode output shows what I expect, but I can't seem to pass any information into dewesoft just 0 or 1 depending on exit status. I tried exit() and sys.exit This is my first time using python so could be another issue. I was hoping to use this to get around the serious lack of methods of getting information into dewesoft.


Gregor Šmit

Posted on 08.08.2022 12:56

Dear Gary,


thank you for trying the solution. When I was testing this I was using the numbers and with the Python it is possible to exit with an integer for example exit(4) would set the Sequencer variable to 4 -> I have look into this a bit more and with the string this can not be done since the exit value can not be strig. May I ask what would you like to achieve?


Kind regards.

Gary Floyd

Posted on 08.08.2022 14:43

The exit value can be a string from python, at least it shows a string at the command prompt. It can’t be a float it appears though. How is dewesoft getting the value, just pulling it from stdinput, ie if it’s displayed on command prompt would it read it in? I was trying to pass values from a csv to global variables. Values would be strings/float/ integers. I was trying to do this since the c++ script you can’t change the file input parameter from the sequencer. I can’t have the user modifying the c++ file input parameter.

Gregor Šmit

Posted on 25.08.2022 09:18

Dear Gary,


if I understand correctly you are using a C++ script inside the Sequencer and you would like to read a CSV file with parameters (strings/float/ integers) and then pass these parameters to the C++ script?


With the C++ script you can read the CSV file and then use the available data. In the attachment I am sending a sample setup file that contains the C++ script. The C++ script requires the .txt file, that is also in the attachment. The C++ script reads the data from the CSV file and writes it to a channel - it essentially replays the data from the .txt file. The input data provided is a sine curve. The setup file includes the ODE plugin, but it is not required for the script to run.


For any additional information please do not hesitate to contact us.



Kind regards.


Attached files:
Gary Floyd

Posted on 25.08.2022 12:21

My two issues with the c++ script is that it does not appear that the file path from the sequencer or variable can be changed, and confirmed from support. I don’t want users to have go into the math screen, scroll past a couple hundred math equations to hopefully get the correct file changed.


Second at least from conversations with support the c++ script can’t do non synchronous output from a csv. However playing around with time bases it’s clear that non synchronous output can be achieved to some extend. My csv has a first column of time, second is position of a valve. So basically the valve will move to a position at the designated time. Using this method the user can simulate any profile they want for as many times as they want.


The time reference curve does everything I need from a technical point but again can’t read in a csv file, and cutting/pasting from excel is again error prone.


This system has upwards of 100 users and is used for production (no changes allowed) or development (free to do what ever they want).

I will take a look at this file, thank you.

Login to reply to this topic. If you don't have account yet, you can signup for free account .