Rolling Your Own
Rolling your own ASCII-to-Numeric-code, here is an example of its principle. Its missing some lines, but the basic is there.
Using a sequense of word's, e.g. BufferWord, BufferWord+1, ..
Load these words with <0> (NUL) and then with the string, but only one ASCII character in each word.
MSB digit (or sign) in BufferWord, next digit/ASCII character in BufferWord+1 and so on.
For PLCs supporting structured text, this could be used almost as is. Those with only ladder or instruction list, have to do some rewriting.
Integer ASCII: If the ASCII-data is Integer-ASCII, e.g. "01234" :
; All variables of type Word
n:=0
sign:=1
dummy:=0
; Assuming the sign in the first character..
IF BufferWord[n]= 45 ; <45> = - character
THEN
sign:= -1
n:=1
END_IF
IF BufferWord[n]= 43 ; <43> = + character
THEN
n:=1
END_IF
WHILE BufferWord[n] != <0> DO
dummy:= dummy * 10
dummy:= dummy + (BufferWord[n] - 48) ; <48> = 0 character
n:=n + 1
END_WHILE
integer:= sign * dummy
Instead of checking different from <0>, one could check: GREATER than <47> AND LESS than <58> since "0" = 48 and "9" = 57
Float-ASCII e.g. "-0123.0012" :
The PLC must support floating number and having a IntToFloat function.
n:=0
NoDec:=1.0 ; Dword with float/real
sign:= 1.0 ; Dword with float/real
floatint:=0.0 ; Dword with float/real
floatdecimal:=0.0 ; Dword with float/real
IF BufferWord[n]= 45 ; <45> = - character
THEN
sign:= -1.0
n:=1
END_IF
WHILE (BufferWord[n] != <0>) AND (BufferWord[n] != <46>) AND (BufferWord[n] != <44>) DO
floatint:=floatint * 10.0
floatint:=floatint + IntToFloat(BufferWord[n]-48) ; <48> = 0 character
n:=n + 1
END_WHILE
IF (BufferWord[n] = <46>) OR (BufferWord[n] = <44>) ; "." OR ","
THEN
n:=n+1
END_IF
WHILE (BufferWord[n] != <0>) DO
floatdecimal:= floatdecimal * 10.0
floatdecimal:= floatdecimal + IntToFloat(BufferWord[n]-48) ; <48> = 0 character
n:=n + 1
NoDec:= NoDec * 10.0
END_WHILE
floatdecimal:=floatdecimal/NoDec
float:= sign*(floatint + floatdecimal)
This is only the basic.Some checks are missing before it is bullet-proof