Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 4th, 2004, 10:06 AM
lloydie-t lloydie-t is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Location: UK
Posts: 523 lloydie-t User rank is Private First Class (20 - 50 Reputation Level)lloydie-t User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 17 h 3 m 13 sec
Reputation Power: 7
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;

Reply With Quote
  #2  
Old January 4th, 2004, 10:28 AM
lloydie-t lloydie-t is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Location: UK
Posts: 523 lloydie-t User rank is Private First Class (20 - 50 Reputation Level)lloydie-t User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 17 h 3 m 13 sec
Reputation Power: 7
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 10:31 AM.

Reply With Quote
  #3  
Old January 5th, 2004, 01:03 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Click here for more information.
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,713 Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 11 h 21 m 11 sec
Reputation Power: 1179
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

Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month

Reply With Quote
  #4  
Old January 5th, 2004, 01:31 PM
lloydie-t lloydie-t is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Location: UK
Posts: 523 lloydie-t User rank is Private First Class (20 - 50 Reputation Level)lloydie-t User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 17 h 3 m 13 sec
Reputation Power: 7
Wrong sort of division for real type / not DIV

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > String/float functions in DLL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT