Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert String To Integer / Real

Status
Not open for further replies.

XRMICHAEL

Technical User
Jan 31, 2008
1
GB
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.
 
Hi

The good old Pascal has no [tt]StrToInt()[/tt] function. If you are using Delphi or Kylix see forum102 or forum755. If not, tell us what flavor are you using.

Feherke.
 
Try the Val procedure

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top