
adccommunitymod (AutomationDirect) asked a question.
Created Date: June 14,2013
Created By: Hamilton Woods
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
I was able to convert a string (text) to a number by using Copy Pack. This worked well when the numeric portion of the string always was in the same text (character) locations. Now I will be receiving a pair of numbers from a barcode scanner. One scan will transmit both numbers, separated by a delimiter. The only way that I can think of to retrieve the two numbers is to search for the delimiter and then perform a Copy Pack for each of the two numbers. It appears that the starting and ending addresses of the Copy Pack cannot be pointers; therefore, a set of Copy Pack rungs will have to be present for each possible location of the delimiter in the text from the barcode scanner. That is: with barcode string in locations TXT1 - TXT11, search for delimiter in TXT1-TXT11. If delimiter index is 2 then Copy Pack TXT1-TXT1 as number 1 and TXT3-TXT11 as number 2. If delimiter index is 3 then Copy Pack TXT1-TXT2 as number 1 and TXT4-TXT11 as number 2. If delimiter index is 4 then Copy Pack TXT1-TXT3 as number 1 and TXT5-TXT11 as number 2. If delimiter index is 5 then Copy Pack TXT1-TXT4 as number 1 and TXT6-TXT11 as number 2. If delimiter index is 6 then Copy Pack TXT1-TXT5 as number 1 and TXT7-TXT11 as number 2. If delimiter index is 7 then Copy Pack TXT1-TXT6 as number 1 and TXT8-TXT11 as number 2. If delimiter index is 8 then Copy Pack TXT1-TXT7 as number 1 and TXT9-TXT11 as number 2. If delimiter index is 9 then Copy Pack TXT1-TXT8 as number 1 and TXT10-TXT11 as number 2. If delimiter index is 10 then Copy Pack TXT1-TXT9 as number 1 and TXT11-TXT11 as number 2. This seems rather "clunky ". Is there a more compact way of doing this? Thanks, Hamilton Woods
Created Date: June 16,2013
Created by: kewakl
The was seeking help using the PAC 3000. Your examples indicate a CLICK.
You can loop through TXT addresses using Single Copy Mode.
But I cannot quickly think of a way that is less clunky than your suggestion.
Created Date: June 16,2013
Created by: kewakl
What sorts of numbers will you be receiving?
What is the delimiter? Is it FIXED or can you modify it?
Created Date: June 17,2013
Created by: Hamilton Woods
Converting to different data types
Good questions.
The Click is being used to verify that the measured watts is between a lower and upper limit. The limits are being scanned from a single label attached to the unit. I haven't really thought about making the delimiter able to be modified. I would just dictate a delimiter, for instance a colon (:).
The numbers that the Click will be receiving are floating point numbers of somewhat arbitrary length - I don't know how easy it would be to force the barcode printing software to format the numbers a particular way.
What I had in mind is accepting any of the following as valid barcode scan entries:
0:100
180.5:200.3
_200.1_:_220.3_
1800.523:1950.278
where "_ " is really a blank (space).
The idea is to determine the location of the delimiter (easy enough) and then to convert everything to the left of the delimiter to a number representing the lower limit and convert everything to the right of the delimiter to a number representing the upper limit.
I have not checked yet to determine if the Click can convert a string that has not been trimmed (a number surrounded by spaces) to a number.
From what I understand so far, I will need a rung (or pair of rungs) for each possible delimiter position to perform the conversions. I would like to know if there is a more elegant solution.
Thanks for your help.
Created Date: June 17,2013
Created by: kewakl
Maybe this should be moved to its own thread. We should not hijack a PAC3000 thread with our CLICK discussion.
Moderator, can you move this?
The numbers that the Click will be receiving are floating point numbers of somewhat arbitrary length - I don't know how easy it would be to force the barcode printing software to format the numbers a particular way.
You have somewhat invalidated my next questions.
They were going to be along the lines of interpreting a FORCED float to two integers.
So I will jump to the next line of questions.
Is the milliwatt precision necessary?
Don't get me wrong, I don't know what you are measuring, so I have to ask these kinds of questions.
Do you require both limits in the same barcode scan?
It seems that CLICK does not have an elegant way to breakout your fields.
Created Date: June 19,2013
Created by: Hamilton Woods
Converting to different data types in Click
Q: Is the milliwatt precision necessary?
A: I don't think so, but I don't think it matters because the conversion from string to floating point should work either way.
Q: Do you require both limits in the same barcode scan?
A: It is not a strict requirement, but the idea was to make operator actions simple with one barcode scan rather than two.
It seems that CLICK does not have an elegant way to breakout your fields.
Response: How sad :( I am confident that I can handle the scanner input using a couple of handfuls of rungs, though.
Thanks for your help.
Created Date: June 20,2013
Created by: kewakl
Q: Is the milliwatt precision necessary?
A: I don't think so, but I don't think it matters because the conversion from string to floating point should work either way.
If float datatype of current limits is not *required* I was thinking of packing the upper and lower into a float.
Eg. 1800.1950 would scan into a float. Then some math to get the INT portion(LOWERLIMIT). The remainder would be multiplied to get it to INT (UPPERLIMIT).
Q: Do you require both limits in the same barcode scan?
A: It is not a strict requirement, but the idea was to make operator actions simple with one barcode scan rather than two.
I had an idea that this was the plan.
It seems that CLICK does not have an elegant way to breakout your fields.
Response: How sad :( I am confident that I can handle the scanner input using a couple of handfuls of rungs, though.
You can always HIDE the inelegant routine that you posted in post 1.
Take all of your If delimiter index is 2 then Copy Pack TXT1-TXT1 as number 1 and TXT3-TXT11 as number 2.
...
If delimiter index is 10 then Copy Pack TXT1-TXT9 as number 1 and TXT11-TXT11 as number 2.
and put it in a subroutine and call it after scanning the barcode.
Later, if an elegant routine is devised, you could replace the ugly with the beauty !
Oh, I experimented a bit with delimiters. The CLICK can replace your chosen delimiter in the TXT locations. There is no need to change your barcode software to handle this.
Created Date: June 14,2013
Created by: Hamilton Woods
I was able to convert a string (text) to a number by using Copy Pack. This worked well when the numeric portion of the string always was in the same text (character) locations.
Now I will be receiving a pair of numbers from a barcode scanner. One scan will transmit both numbers, separated by a delimiter. The only way that I can think of to retrieve the two numbers is to search for the delimiter and then perform a Copy Pack for each of the two numbers. It appears that the starting and ending addresses of the Copy Pack cannot be pointers; therefore, a set of Copy Pack rungs will have to be present for each possible location of the delimiter in the text from the barcode scanner. That is:
with barcode string in locations TXT1 - TXT11, search for delimiter in TXT1-TXT11.
If delimiter index is 2 then Copy Pack TXT1-TXT1 as number 1 and TXT3-TXT11 as number 2.
If delimiter index is 3 then Copy Pack TXT1-TXT2 as number 1 and TXT4-TXT11 as number 2.
If delimiter index is 4 then Copy Pack TXT1-TXT3 as number 1 and TXT5-TXT11 as number 2.
If delimiter index is 5 then Copy Pack TXT1-TXT4 as number 1 and TXT6-TXT11 as number 2.
If delimiter index is 6 then Copy Pack TXT1-TXT5 as number 1 and TXT7-TXT11 as number 2.
If delimiter index is 7 then Copy Pack TXT1-TXT6 as number 1 and TXT8-TXT11 as number 2.
If delimiter index is 8 then Copy Pack TXT1-TXT7 as number 1 and TXT9-TXT11 as number 2.
If delimiter index is 9 then Copy Pack TXT1-TXT8 as number 1 and TXT10-TXT11 as number 2.
If delimiter index is 10 then Copy Pack TXT1-TXT9 as number 1 and TXT11-TXT11 as number 2.
This seems rather "clunky ". Is there a more compact way of doing this?
Thanks,
Hamilton Woods