I am working on a project where I am trying to create a default string that is "RUNA#####", where ##### starts at "0001" and increments based on some other logic.
I am able to make this work using the logic:
GVLP.rBatchID := GVLP.rBatchID +1;
GVLP.wsBatchID:= WConcat("RUNA",REAL_TO_WSTRING(GVLP.rBatchID));
The problem I am having it getting the RealValue to always be 5 Digits.
Has anyone tried to do this and/or have any tips what I can try to get this to work??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah ok. I guess a REAL value will still work as good, I just find it strange to use a REAL when I will never have any decimal places.
Here is another one, which does exactly the same thing as the first.
Are you in simulation mode? This only works when not in Simulation mode.
You can use the Soft PLC that comes with the IDE installer. Just start it from the Systray.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I may not be following what youre trying to explain and I apologize if that is the case. What I have found is...
if I create a text block on my VISU and set the text to "RUNA%05d" then set the text variable to "GVLP.iBatchID", this outputs exactly what I need "RUNA0001, RUNA0002, etc.". I just don't know to get that string into a Variable that I can use elsewhere. It would be great if I could use the concat and somehow tell it to use the format %05d for the Integer when concat'ing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So I've had some more thoughts on this and I am wondering if commands exist that will let me do this....
Take the iBatchID Integer and concat together "0000" and iBatchID to get "0000###". Then is there a command where I can take just the 5 characters from the Right of this? Thus removing the excess leading 0's? Then I can use another concat to put "RUNA" in front of it.
Obviously I know concat is there, but is there a command that will allow me to just select the 5 characters from right to left ??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am working on a project where I am trying to create a default string that is "RUNA#####", where ##### starts at "0001" and increments based on some other logic.
I am able to make this work using the logic:
GVLP.rBatchID := GVLP.rBatchID +1;
GVLP.wsBatchID:= WConcat("RUNA",REAL_TO_WSTRING(GVLP.rBatchID));
The problem I am having it getting the RealValue to always be 5 Digits.
Has anyone tried to do this and/or have any tips what I can try to get this to work??
more posts ...
Why is your batchid a real, if you only have integer values?
Anyway, for a REAL you can do:
"Why is your batchid a real, if you only have integer values?" because I don't necessarily know EXACTLY what I'm doing.
How would that logic be modified if I were to use Integer rather than Real?
Ah ok. I guess a REAL value will still work as good, I just find it strange to use a REAL when I will never have any decimal places.
Here is another one, which does exactly the same thing as the first.
I have to be missing something here. I am unsure what output I should be getting from the StuSprintfW function.
Are you in simulation mode? This only works when not in Simulation mode.
You can use the Soft PLC that comes with the IDE installer. Just start it from the Systray.
I may not be following what youre trying to explain and I apologize if that is the case. What I have found is...
if I create a text block on my VISU and set the text to "RUNA%05d" then set the text variable to "GVLP.iBatchID", this outputs exactly what I need "RUNA0001, RUNA0002, etc.". I just don't know to get that string into a Variable that I can use elsewhere. It would be great if I could use the concat and somehow tell it to use the format %05d for the Integer when concat'ing.
So I've had some more thoughts on this and I am wondering if commands exist that will let me do this....
Take the iBatchID Integer and concat together "0000" and iBatchID to get "0000###". Then is there a command where I can take just the 5 characters from the Right of this? Thus removing the excess leading 0's? Then I can use another concat to put "RUNA" in front of it.
Obviously I know concat is there, but is there a command that will allow me to just select the 5 characters from right to left ??
Got it. Just incase any one else comes across this....
GVLP.iBatchID := GVLP.iBatchID + 1;
GVLP.wsBatchID := WConcat("0000", INT_TO_WSTRING(GVLP.iBatchID));
GVLP.wsBatchID := WRight(GVLP.wsBatchID,5);
GVLP.wsBatchID := WConcat("RUNA",GVLP.wsBatchID);