Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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 December 10th, 2003, 02:48 PM
lloydie-t lloydie-t is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Location: UK
Posts: 563 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 23 h 54 m 22 sec
Reputation Power: 12
Why Can't I get a For loop working

I cant see what I am doing wrong in this for loop. I can do it easy in PHP, but because I am new to Delphi I just don't get it.Can some one point me in the right direction?
Code:
procedure TMainForm.CdrButtonOKClick(Sender: TObject);
var
i : integer;
j : integer;
k : pchar;
begin
Assignfile(CdrText, CdrImportEdit.Text);
Reset(CdrText);
while not EOF(CdrText) do begin
ReadLn (CdrText, Buffer1);
ExtVar := PhoneNum(buffer1);
for i = strlen(Pchar(ExtVar)) downto 1 do
begin
areacode := copy(ExtVAr, 0,i) : string;
mySQLCollexClient.Query.PrepareTask (Pchar(SELECT * FROM stdcodes
WHERE areacode = '+areacode,nil,nil,AnyThreadedError;
SQLClient.Execute;
j := mySQLCollexClient.Query.DataCount;
SQLClient.Query.Clear;
if j > 0 then break;
end;
begin
mySQLCollexClient.Query.PrepareTask (Pchar(SELECT * FROM stdcodes
WHERE areacode = '+areacode,nil,nil, AnyThreadedError;
SQLClient.Execute;
k := mySQLCollexClient.Query.Data;
SQLClient.Query.Clear;
end;
edit1.Text := (ExtVar);
end;
CloseFile(CdrText);
end;


Errors---------------------------------------

[Warning] datacollex.pas(117): Comparing signed and unsigned types - widened both operands
[Error] datacollex.pas(117): For loop control variable must be simple local variable
[Error] datacollex.pas(118): Expression expected but 'BEGIN' found
------------------------------------------------
WhaDaYaTink?

Reply With Quote
  #2  
Old December 11th, 2003, 12:53 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is online now
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,406 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 9 h 47 m 28 sec
Reputation Power: 4080
For one thing, you have:
for i = strlen(Pchar(ExtVar)) downto 1 do
when it should be (notice the := )
for i := strlen(Pchar(ExtVar)) downto 1 do

Also, this line won't work:
areacode := copy(ExtVAr, 0,i) : string;

Remove the ":string" from the line. Hope this helps
__________________
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

Reply With Quote
  #3  
Old December 11th, 2003, 02:19 AM
lloydie-t lloydie-t is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Location: UK
Posts: 563 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 23 h 54 m 22 sec
Reputation Power: 12
Can't shake the PHP monkey.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Why Can't I get a For loop working

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap