PC Review


Reply
Thread Tools Rate Thread

"Continue" and Exit with For Loops

 
 
=?Utf-8?B?QW5kcmV3IEhhbGwgTlo=?=
Guest
Posts: n/a
 
      22nd Nov 2006
Most of my recent scripting has been with Javascript (for Photoshop). With
For Loops I am missing the ability to use a 'continue' command which skips to
the next iteration of the for loop. I can achieve the same with IF statements
but sometimes, when one is already within a series of nested IF statements,
this becomes rather cumbersome. I suspect I can also achieve it with
functions and / or subroutines but again that looks a messy to me. I guess I
could use Go To the first line inside the loop, while resetting the counter
(though that won't work in For Each).

How do the pro's do it in VBA?

One other question while I am at it. One of the best methods for learning
Photoshop Javascript was to got to the Adobe Share Scripts site and download
scripts and look at them. Is there an equivalent for VBA you would recommend.

TIA

Andrew
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QW5kcmV3IEhhbGwgTlo=?=
Guest
Posts: n/a
 
      22nd Nov 2006
I realize I forgot to add another colosely related issue - exiting out of
nested For loops. I can do this using a boolean variable in the inner loop
that then is tested in the outer loop but is there a better way (perhaps GoTo
again)

Andrew
 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      22nd Nov 2006
Nested IFs is the way I do it, with breakouts to functions.

I suppose that you could add a single iteration For ... Next loop, and Exit
For within that, but seems kludgy to me.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Andrew Hall NZ" <(E-Mail Removed)> wrote in message
news:269822D0-5F79-4419-8E0C-(E-Mail Removed)...
> Most of my recent scripting has been with Javascript (for Photoshop). With
> For Loops I am missing the ability to use a 'continue' command which skips

to
> the next iteration of the for loop. I can achieve the same with IF

statements
> but sometimes, when one is already within a series of nested IF

statements,
> this becomes rather cumbersome. I suspect I can also achieve it with
> functions and / or subroutines but again that looks a messy to me. I guess

I
> could use Go To the first line inside the loop, while resetting the

counter
> (though that won't work in For Each).
>
> How do the pro's do it in VBA?
>
> One other question while I am at it. One of the best methods for learning
> Photoshop Javascript was to got to the Adobe Share Scripts site and

download
> scripts and look at them. Is there an equivalent for VBA you would

recommend.
>
> TIA
>
> Andrew



 
Reply With Quote
 
Stephen Rasey
Guest
Posts: n/a
 
      23rd Nov 2006
'This structure assumes that for each object, many work blocks can be
processed on each object.

Dim bSkip as Boolean ' logic if true, then skip rest of for loop.
For Each obj1 in objects
bSkip = False
[Work block1
bSkip = true or false]
if bSkip Then Goto ForEndA
[Work block2
bSkip = true or false]
if bSkip Then Goto ForEndA
[Work block3
bSkip = true or false]
....
ForEndA:
last steps every object need do before next object.
Next

-Stephen Rasey



 
Reply With Quote
 
=?Utf-8?B?QW5kcmV3IEhhbGwgTlo=?=
Guest
Posts: n/a
 
      23rd Nov 2006
Nice one Stephen, that's exactly what I was looking for and it's very general

Andrew
 
Reply With Quote
 
 
 
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
renaming "Exit Access" to "Exit" ds Microsoft Access 0 5th Feb 2009 04:58 PM
renaming "Exit Access" command to "Exit" in Access 2007 dstork@gmail.com Microsoft Access 2 10th Mar 2008 08:16 PM
Change default in input box from "20" to "000000"? Have macro continue on to name sheet tab? StargateFanFromWork Microsoft Excel Programming 8 30th Oct 2006 07:26 PM
Automatically click "Update Links" & "Continue" paulharvey Microsoft Excel Programming 0 3rd Jun 2006 05:35 PM
Windows Messenger (4.7.2009) does not exit when I click "Exit" Paul-133 Windows XP Messenger 1 22nd Apr 2004 07:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:33 PM.