Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Strange behavior...

May
855
0
The following code works as expected:

For /L %IDX In (0,1,%TDX) Do (
@Echo %IDX %CmdLnths[%IDX] %CmdNames[%IDX]
)

The following code does not (at all!!!!! - it does exactly one iteration of the loop :confused:):

Set IDX=0
Do While %IDX LE %TDX
@Echo %IDX %CmdLnths[%IDX] %CmdNames[%IDX]
Set IDX=%Inc[%IDX]
EndDo

There are no other changes to the code other than what's shown here between working and not working. The reason I care is because I have other do-while loops in the code that also do not appear to work, and they really can't be turned into "for" loops because they are not "counted" loops. Please excuse my evident stupidty, but what is going on here????

TCC 10.00.67 Windows 7 [Version 6.1.7100]
 
---- Original Message ----
From: mathewsdw
To: [email protected]
Sent: Saturday, 2010. October 30. 00:57
Subject: [Support-t-2387] Strange behavior...

| The following code works as expected:
|
| For /L %IDX In (0,1,%TDX) Do (
| @Echo %IDX %CmdLnths[%IDX] %CmdNames[%IDX]
| )
|
| The following code does not (at all!!!!! - it does exactly one
| iteration of the loop ):
|
| Set IDX=0
| Do While %IDX LE %TDX
| @Echo %IDX %CmdLnths[%IDX] %CmdNames[%IDX]
| Set IDX=%Inc[%IDX]
| EndDo
|
| There are no other changes to the code other than what's shown here
| between working and not working. The reason I care is because I have
| other do-while loops in the code that also do not appear to work, and
| they really can't be turned into "for" loops because they are not
| "counted" loops. Please excuse my evident stupidty, but what is going
| on here????
|
| TCC 10.00.67 Windows 7 [Version 6.1.7100]

Simple - your increment command is misspelled, the @ symbol is missing from the function name (penultimate line of 2nd code fragement). BTW, DO also cas a "counted" mode:

Do IDX = 0 to %TDX
@Echo %IDX %CmdLnths[%IDX] %CmdNames[%IDX]
EndDo
--
HTH, Steve
 
---- Original Message ----
From: mathewsdw
To: [email protected]
Sent: Saturday, 2010. October 30. 00:57
Subject: [Support-t-2387] Strange behavior...

| ...
|
| The following code does not (at all!!!!! - it does exactly one
| iteration of the loop ):
|
| Set IDX=0
| Do While %IDX LE %TDX
| @Echo %IDX %CmdLnths[%IDX] %CmdNames[%IDX]
| Set IDX=%Inc[%IDX]
| EndDo
|
| ...

Simple - your increment command is misspelled, the @ symbol is missing from the function name (penultimate line of 2nd code fragement). BTW, DO also cas a "counted" mode:

Do IDX = 0 to %TDX
@Echo %IDX %CmdLnths[%IDX] %CmdNames[%IDX]
EndDo
--
HTH, Steve

Steve, you are of course absolutely correct regarding your answer, but, unfortunately, I wasn't correct in writing my posting. I didn't copy and paste the code in question into my posting, I transcribed it and made a transcription error - i. e., my actual code does have the missing @ symbol, and no, it still doesn't work. But the other code in question does now work (I found my coding error(s)), and since this code with the "for" loop does work, I'm not going to waste any more of my (or your, for that matter) time on this matter since I now consider it to be a dead issue. I will also note (possibly again) that I am somewhat visually impaired (I have to do everything with either a very large font (18 pt. or greater) or the Windows "Magnifier" app), so I often miss "little" things of this nature - but that wasn't the case for the code in question. But thank you very much for your response!

- Dan
 

Similar threads

Back
Top