January 4th, 2004, 10:06 AM
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?
Function LenOfCallHr (S: String): String; stdcall;
Result := copy(S,37,2);
Function LenOfCallMin (S: String): String; stdcall;
Result := copy(S,40,2);
Function LenOfCallSec (S: String): String; stdcall;
Result := copy(S,43,2);
January 4th, 2004, 10:28 AM
Can I get away with doing something like.
Function LenOfCall (S: String): Real; stdcall;
Result := ((StrToFloat(copy(S,37,2))*60)+(StrToFloat(copy(S,40,2)))+((StrToFloat(copy(S,40,2)) DIV 60));
Last edited by lloydie-t; January 4th, 2004 at 10:31 AM.
January 5th, 2004, 01:03 PM
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
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
January 5th, 2004, 01:31 PM
Wrong sort of division for real type / not DIV