DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

substr & strfmt

Solved!
Go to solution

Hey

 

I have a text string of 24 digits (too long for a variable). I want to convert the first 3 digits to a variable.
I know I should use substr and strfmt commands, but how do I implement them in Dasylab?
Regards
Benny
Denmark
0 Kudos
Message 1 of 9
(10,517 Views)

Which version DASYLab do you have?

 

How do you get the string? via RS232?

Tom Rizzo
InSyS Corp.
www.insyscorp.com
Your DASYLab integrator
0 Kudos
Message 2 of 9
(10,512 Views)

Hey

 

I using both Ver 8 and 9.  I am rebuilding our oldest test machine (ver 8 ).

 

The input er by barcode reader. Input from keyboard by Action -> Enter String.

 

Regards

 

Benny

0 Kudos
Message 3 of 9
(10,510 Views)

I just realized that I didn't install DASYLab in this lapto but, unless somebody can answer this today, I will try this weekend.  I am not atthe office today.

 

In any case, in Ver 9, you can perform many string manipulation action in the string variable section.

Tom Rizzo
InSyS Corp.
www.insyscorp.com
Your DASYLab integrator
0 Kudos
Message 4 of 9
(10,508 Views)
Solution
Accepted by topic author Højvælde

This should be the same in V8 and V9.

 

Set up an extended Expression in a global variable

 

The formula is

 

strval(substr ( ${STR_1}, 1,3 ) )

 

 

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
0 Kudos
Message 5 of 9
(10,506 Views)

Hey

 

Yes it is solved.

 

Regards

 

Benny

0 Kudos
Message 6 of 9
(10,501 Views)

error data type.jpg

I use the Expression in the variable property setting. The formular is:  strval (substr (${STR_1} ,3 , 4) )

It works well in my simulation program. But when I write this small program with my main program, it shows some error. The screenshot ist linked to this subject. Al the setting are same. I am so confused. Can somebody help me?? I  will very appreciate that.

 

Thank you very much!!

0 Kudos
Message 7 of 9
(5,578 Views)

I do not get this message when I set up as you have done. 

 

What does the current value of the string look like? 

 

Also, what version of DASYLab are you using? 

 

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 8 of 9
(5,573 Views)

String.jpg

Hi CJ,

I  want to use Dasylab to collect some data from a device through a RS232 module.

There are 2 types of Intput Signal. One is started with "A" and the other one is started with "B". And I have already set these two Signals into String 1 and 2. (use fomular "A" a $1 \r) Now I want to seperate these String into different variables. An example is showed below.

string1: 861200  into Variable1: 86  Variable2: 1200

Version of DASYLab is 2016 Basic

0 Kudos
Message 9 of 9
(5,569 Views)