Lost Again...Step Increment

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: May 2008
Posts: 5
Reputation: gh0sts416 is an unknown quantity at this point 
Solved Threads: 0
gh0sts416 gh0sts416 is offline Offline
Newbie Poster

Lost Again...Step Increment

 
0
  #1
Feb 9th, 2009
I Was Just Wondering is Ther Anyway At All
To Reproduce A VB Step Increment in Delphi.

VB Example:
for i = 0 to 100 step 10

Delphi: ???

Any Help Would Be A Blessing

Thanks,
gh0sts
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: gh0sts416 is an unknown quantity at this point 
Solved Threads: 0
gh0sts416 gh0sts416 is offline Offline
Newbie Poster

Re: Lost Again...Step Increment

 
0
  #2
Feb 9th, 2009
I Got It Figured Out

But Any Feed Back Would Still Be Appreciated.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Lost Again...Step Increment

 
0
  #3
Feb 9th, 2009
Step is something that delphi kinda overlooked.

Easiest answer is a while loop.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 470
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 113
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: Lost Again...Step Increment

 
0
  #4
Mar 1st, 2009
  1. Program increment_for;
  2. Uses Crt;
  3. Var i:Byte;
  4.  
  5. Begin
  6. ClrScr;
  7. For i:=0 To 100 Do
  8. Begin
  9. If i>=100 Then Break;
  10. Inc(i,20); {increment i with 20}
  11. Write(i, ' ');
  12. Dec(i); {decrement i with 1}
  13. End;
  14.  
  15. Repeat
  16. Until KeyPressed;
  17. End.
In the turbo pascal there is a function called INC(number,increment) and I think that the pascal was the base of the delphi
Last edited by FlamingClaw; Mar 1st, 2009 at 5:20 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Lost Again...Step Increment

 
0
  #5
Mar 1st, 2009
most languages dont like you messing with the itterator. You would do better to use a while loop.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 470
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 113
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: Lost Again...Step Increment

 
0
  #6
Mar 2nd, 2009
I think you're right,the
  1. While..Do
or the
  1. Repeat..Until
can be the right way,'cause these statements are used for that....the point is yours...
With respect FlamingClaw
Last edited by FlamingClaw; Mar 2nd, 2009 at 2:32 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 470
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 113
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: Lost Again...Step Increment

 
0
  #7
Mar 29th, 2009
Ok,I know that this thread is not fresh but I have an idea,and working!
  1. {
  2. Question
  3. Increment for loop
  4. }
  5. Program Program01;
  6.  
  7. var i:Byte;
  8.  
  9. Begin {main}
  10. For i:=1 To 100 Do
  11. Begin
  12. i:=i+9; {will step 10}
  13. Write(i,' ');
  14. End;
  15. ReadLn;
  16. End.
  17.  
  18. {
  19. -= Note By FlamingClaw =-
  20.  
  21. All programs created by me are written and tested
  22. in Dev Pascal and/or Turbo Pascal 7.0
  23.  
  24. -= Created By FlamingClaw =-
  25. -=2009.03.29=-
  26. }
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 68
Reputation: jsosnowski is an unknown quantity at this point 
Solved Threads: 11
jsosnowski's Avatar
jsosnowski jsosnowski is offline Offline
Junior Poster in Training

Re: Lost Again...Step Increment

 
0
  #8
Mar 30th, 2009
FlamingClaw,
Two thoughts on your example:

1.) i := i + 9; // does not increment by 10
2.) Using the For statement could easily lead to an error in a large body of code. Imagine coming back to this a year from with no memery of the logic. You would see the For statement and assume an increment of 1 with the For statement controling the i variable. It would be better to use a With or Repeat statement because you would still seek out the increment line to evaluate the step size.
Last edited by jsosnowski; Mar 30th, 2009 at 10:08 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 470
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 113
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: Lost Again...Step Increment

 
0
  #9
Mar 30th, 2009
try it and you'll see that i:=i+9 will every round 10,cause when run this example you will see that every round value of i will increasing by 1....therefor nedd i:=i+9
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 68
Reputation: jsosnowski is an unknown quantity at this point 
Solved Threads: 11
jsosnowski's Avatar
jsosnowski jsosnowski is offline Offline
Junior Poster in Training

Re: Lost Again...Step Increment

 
0
  #10
Mar 30th, 2009
FlamingClaw,

My bad, you are right.

However, overiding the automatic increment still looks like a bad practice.
Last edited by jsosnowski; Mar 30th, 2009 at 12:47 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2130 | Replies: 9
Thread Tools Search this Thread



Tag cloud for Pascal and Delphi
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC