The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Delphi Programming
|
String/float functions in DLL
Discuss String/float functions in DLL in the Delphi Programming forum on Dev Shed. String/float functions in DLL Delphi Programming forum discussing Delphi related topics including Kylix, C++ Builder, and more. Delphi is a high-performance language, originally based on the PASCAL language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 4th, 2004, 09:06 AM
|
|
Contributing User
|
|
Join Date: May 2002
Location: UK
Posts: 563

Time spent in forums: 1 Day 23 h 54 m 22 sec
Reputation Power: 12
|
|
|
String/float functions in DLL
I am using some functions in a DLL I wrote to create some strings from a line of text. I need to convert some of these strings to float(real) within a function. Can someone expalin to me how?
Code:
Function LenOfCallHr (S: String): String; stdcall;
Begin
Result := copy(S,37,2);
end;
Function LenOfCallMin (S: String): String; stdcall;
Begin
Result := copy(S,40,2);
end;
Function LenOfCallSec (S: String): String; stdcall;
Begin
Result := copy(S,43,2);
end;
|

January 4th, 2004, 09:28 AM
|
|
Contributing User
|
|
Join Date: May 2002
Location: UK
Posts: 563

Time spent in forums: 1 Day 23 h 54 m 22 sec
Reputation Power: 12
|
|
Can I get away with doing something like.
Code:
Function LenOfCall (S: String): Real; stdcall;
Begin
Result := ((StrToFloat(copy(S,37,2))*60)+(StrToFloat(copy(S,40,2)))+((StrToFloat(copy(S,40,2)) DIV 60));
end;
Last edited by lloydie-t : January 4th, 2004 at 09:31 AM.
|

January 5th, 2004, 12:03 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Looks like it should work, provided you're extracting the right substrings of course  .
One thing to remember is that if you're calling this DLL from an application written in another programming language, their idea of a float/real type may be different from what Delphi uses (i.e. number of bytes used for the variable, precision etc.), so you may not be able to use it with other languages.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

January 5th, 2004, 12:31 PM
|
|
Contributing User
|
|
Join Date: May 2002
Location: UK
Posts: 563

Time spent in forums: 1 Day 23 h 54 m 22 sec
Reputation Power: 12
|
|
|
Wrong sort of division for real type / not DIV
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|