02-15-2018 02:20 AM
Hi everyone!
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
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.
Best wishes,
Hartmut
02-15-2018 08:40 AM
You said, in the other thread,
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
Can you post the worksheet? Hopefully, the Global String will be saved with some data.
02-15-2018 08:56 AM
Sorry I can't, because the main program is not allowed to be uploaded. But I can say that the setting in the main program is exactly same as I have posted. Can you tell how to check if the Global String will be saved with some data. Thank you so much!!
02-15-2018 09:04 AM
If you cannot send the full program, do a print screen of the Define Global Strings dialog showing that string.
Usually, the values in the strings and variables are saved with the worksheet when you save.
02-16-2018 01:26 AM
02-19-2018 01:18 AM
Hello CJ,
I think I have find where the problem is.
When I used StrVal (SubStr (${STR_1} ,3,4)), “STR_1” is the error.
When I used StrVal (SubStr (${STR_2} ,3,4)), “STR_2” is the error.
When I used StrVal (SubStr (${STR_3} ,1,4)), “1” is the error.
When I used StrVal (SubStr (${STR_3} ,3,2)), “2” is the error.
When I used StrVal (SubStr (${STR_3} ,3,4)), there is no error any more.
So, I think the error is 1 and 2. I cannot use these two numbers.