Convert String To Integer / Real
Convert String To Integer / Real
(OP)
Hi, sorry if this seem a bit of a simply ? but i only have a need to write very basic programs.
I have to write a small programme to read a serial output from a device and represent the level data on a touch screen.
The screen can only show levels that are real/integer values.
I have stripped the relevant byte of level information with
ZONE1LEVEL:=(RECEIVEDDATA[6]);
I then try and ZONE1LEVEL:=STRINGTOINT byte 6 from above data, but ZONE1LEVEL always = 0.
With my limited knowledge stringtoint will result in 0 if the data to be converted is not something or other.
Byte 6 above will be in the range of #00 to #64
Any help greatly received.
I have to write a small programme to read a serial output from a device and represent the level data on a touch screen.
The screen can only show levels that are real/integer values.
I have stripped the relevant byte of level information with
ZONE1LEVEL:=(RECEIVEDDATA[6]);
I then try and ZONE1LEVEL:=STRINGTOINT byte 6 from above data, but ZONE1LEVEL always = 0.
With my limited knowledge stringtoint will result in 0 if the data to be converted is not something or other.
Byte 6 above will be in the range of #00 to #64
Any help greatly received.
RE: Convert String To Integer / Real
The good old Pascal has no StrToInt() function. If you are using Delphi or Kylix see forum102: CodeGear (Borland): Delphi or forum755: CodeGear (Borland): Kylix. If not, tell us what flavor are you using.
Feherke.
http://rootshell.be/~feherke/
RE: Convert String To Integer / Real
Val( TextVal, Number , Code) which converts String to a number.
if this is possible the result of code = 0, other wise code indicates the character where
the error occurred
example:
Textval := '354';
Val(Textval, Number, Code) ---> Code = 0, Number = 354
Textval := '37645x2';
Val( Textval, Number, Code) ---> Code = 6, Number remains unchanged;
Steven