Hello everyone, I need to change from the PLC code the Text property of a rectangle.
To display two decimal i use the following string "% .2f", but I predict that it will also change to three decimal "% .3f".
Please someone can post a code sample that uses the Visu library?
Thank You.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
perhaps I expressed myself badly, I try to explain it again:
In one visualization screen i have one rectangle for display one variable value.
wehn i develop, if i put the text name %.2f , in run mode i see the value with two decimal point.
The question is: i want switch from code %.2f or %.3f ... is possible? if yes how?
Second question, this format is possible only for floating point variable or is possible also for integer variable (eg. %.2d)?
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2017-01-17
Originally created by: Massimo.Milluzzo
I think it is not possible to change %.2f into %.3f because this is a design time parameter.
Integer variables don't have a decimal portion, the '.#' string is ignored. If you want you can create a floating point variable to show. In your routine convert the integer into a float.
Anyway, why do you want to show an integer as #.00 if it cannot uses decimal values? This could confuse the user
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks for the reply
Too bad you can not do
Perhaps the best way is to use the string?
By formatting the string in the code and then displays it in a rectangle?
Zitat:
Anyway, why do you want to show an integer as #.00 if it cannot uses decimal values? This could confuse the user
is a programming technique to use integers for display the decimal as is necessary for the application, the use of a float commits more resources, but this would be less important than the ability to change the format of the code and for the user is not understandable.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2017-01-17
Originally created by: Massimo.Milluzzo
elsabz hat geschrieben:
is a programming technique to use integers for display the decimal as is necessary for the application, the use of a float commits more resources, but this would be less important than the ability to change the format of the code and for the user is not understandable.
Ah ok, like in WinCC Flexible.
A workaround could be to set the 'Text variable' as expression. See the attachment
is the integer variable to display, is the scale factor. In your situation should be 10,100,1000 etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found the solution to the problem, with the method of the strings %s
I also managed to improve because I have also introduced the minutes
//GlobalVariable  gvl.Tempo_A:DWORD;// TIME();  gvl.testStringa:STRING;  gvl.testBoleana:BOOL;//FunctionBlockVAR  min:STRING;  sec:STRING;  cent:STRING;  mill:STRING;  x:DWORD;  a:DWORD;    b:DWORD;  c:DWORD;END_VARmin:=DWORD_TO_STRING(gvl.Tempo_A/60000);x:=(gvl.Tempo_A/1000)MOD60;b:=xMOD10;a:=(x-b)/10;sec:=Concat(DWORD_TO_STRING(a),DWORD_TO_STRING(b));x:=(gvl.Tempo_AMOD1000)/10;b:=(gvl.Tempo_A/10)MOD10;a:=(x-b)/10;cent:=Concat(DWORD_TO_STRING(a),DWORD_TO_STRING(b));x:=gvl.Tempo_AMOD1000;c:=xMOD10;b:=(gvl.Tempo_A/10)MOD10;a:=(x-b)/100;mill:=Concat(DWORD_TO_STRING(a),Concat(DWORD_TO_STRING(b),DWORD_TO_STRING(c)));IFgvl.testBoleanaTHENgvl.testStringa:=Concat(Concat(Concat(Concat(min,':'),sec),'.'),mill);ELSEgvl.testStringa:=Concat(Concat(Concat(Concat(min,':'),sec),'.'),cent);END_IF Â
I think this is the only solution if there is another way someone enlighten me
Thanks ... and good job
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2017-01-17
Originally created by: Massimo.Milluzzo
Ok, nice solution.
(Ma sei italiano?)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone, I need to change from the PLC code the Text property of a rectangle.
To display two decimal i use the following string "% .2f", but I predict that it will also change to three decimal "% .3f".
Please someone can post a code sample that uses the Visu library?
Thank You.
perhaps I expressed myself badly, I try to explain it again:
In one visualization screen i have one rectangle for display one variable value.
wehn i develop, if i put the text name %.2f , in run mode i see the value with two decimal point.
The question is: i want switch from code %.2f or %.3f ... is possible? if yes how?
Second question, this format is possible only for floating point variable or is possible also for integer variable (eg. %.2d)?
Thanks in advance
Originally created by: Massimo.Milluzzo
I think it is not possible to change %.2f into %.3f because this is a design time parameter.
Integer variables don't have a decimal portion, the '.#' string is ignored. If you want you can create a floating point variable to show. In your routine convert the integer into a float.
Anyway, why do you want to show an integer as #.00 if it cannot uses decimal values? This could confuse the user
thanks for the reply
Too bad you can not do
Perhaps the best way is to use the string?
By formatting the string in the code and then displays it in a rectangle?
is a programming technique to use integers for display the decimal as is necessary for the application, the use of a float commits more resources, but this would be less important than the ability to change the format of the code and for the user is not understandable.
Originally created by: Massimo.Milluzzo
Ah ok, like in WinCC Flexible.
A workaround could be to set the 'Text variable' as expression. See the attachment
is the integer variable to display, is the scale factor. In your situation should be 10,100,1000 etc.
Yes or Movicon
ok with expression is cool ... but if you set the text to %f in run i see 6 decimal point
Originally created by: Massimo.Milluzzo
You can set the text as %.2f
The problem is, as far as I know, you cannot modify the number of decimal at runtime
I found the solution to the problem, with the method of the strings %s
I also managed to improve because I have also introduced the minutes
I think this is the only solution if there is another way someone enlighten me
Thanks ... and good job
Originally created by: Massimo.Milluzzo
Ok, nice solution.
(Ma sei italiano?)
Si