String to Lint

JosephMont

Member
Join Date
Oct 2014
Location
Yakima
Posts
67
Hello

I have a 13 digit number I need use so a DINT is out. The number originates as a String, and I need to put that number into a LINT.

I saw you can copy (cop/cps) LINT's so I have tried that. I put 123456789123 into the string and used the LEN from the string in the length of the cop to determine size but it is not returning '123456789123', Its returning "3761405299819282444"

I tried a REAL but it rounds due to the standards. so 123456789123 becomes 12345690 etc

Cliff notes: 13 digit string, I need into a LINT.
 
COP/CPS is not what you want to use. That will perform a byte-for-byte copy of the contents of one tag to another. There is no type conversion.

The first thing you need to do is convert the string into an integer. You probably won't be able to do that in one step since I don't think the string manipulation and conversion instructions will take a LINT as a data type. I could be wrong on this, though.

The instruction you are looking for is STOD.

Keith
 
COP/CPS is not what you want to use. That will perform a byte-for-byte copy of the contents of one tag to another. There is no type conversion.

The first thing you need to do is convert the string into an integer. You probably won't be able to do that in one step since I don't think the string manipulation and conversion instructions will take a LINT as a data type. I could be wrong on this, though.

The instruction you are looking for is STOD.

Keith

"The instruction you are looking for is STOD." I tried this. 12345689123 in the string, and found a LINT is just 2 Dints so I tried the STOD with a DINT[1], It maxed out DINT[0].

This was my original logic until the barcode increased in digits passed what a DINT can handle.

I think going from a string to lint is the hardest way possible. I am looking at keeping it a string.
 
COP/CPS is not what you want to use. That will perform a byte-for-byte copy of the contents of one tag to another. There is no type conversion.

The first thing you need to do is convert the string into an integer. You probably won't be able to do that in one step since I don't think the string manipulation and conversion instructions will take a LINT as a data type. I could be wrong on this, though.

The instruction you are looking for is STOD.

Keith

Hey that would work if I took the LEN of the string and divided it by half and placing into a dint to keep a whole number and separated that way then went into the LINT
 
One approach is to convert each digit of the string into a DINT, leaving you with an array of 13 DINTs. Then use LINT-related AOI functions in Rockwell sample code to multiply each digit by the appropriate power of 10 and add to a running sum.

There is an example of this in the T_TtoL AOI, which converts the 7-DINT date-time string to a LINT. It is not exactly comparable, but contains helper AOIs, specifically L_MUL and L_ADD, needed for the task. (This is sample code ID 78107).

I did not see a direct solution in the sample library (e.g., STOL), though it may be part of another AOI.
 
Last edited:
The following attachment uses the AOI functions in the previously referenced Rockwell code sample. LINT_String contains the string to be converted, assumed left-to-right as MSD to LSD, and converted result is in LINT_Result. The tag LINT_10xx9 contains the value 1000000000. Tags named ...Lint are of type LINT and ...Dint are DINT.

STOLINT.jpg
 

Similar Topics

I am creating a global object in FTView SE 13. I want to have a string read from the PLC and display (in this case the tagname). So lets say...
Replies
4
Views
167
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
427
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
128
As the title says, I'm using CCW with a PV800 (and Micro850). I've made a scheduler in which a user can choose a month, day (1-31), hour (0-23)...
Replies
15
Views
507
Hello, So i managed to read the string coming from control logix and put a string display in PanelView 800. Now I am struggling to do the other...
Replies
1
Views
138
Back
Top Bottom