if working in vba, current procedure go this:
do while myfile.atendofstream <> true arrrecord = split(myfile.readline, ",") ' make array of values in line 'there records don't want process: if arrrecord(1) <> "usa" goto skip if arrrecord(0) <= "12/31/2001" goto skip ' otherwise, run rest of code on record skip: loop
but i'm working in vbscript, doesn't have kind of goto function.
i'm thinking of doing same thing delibaratly raising error. instance:
do while myfile.atendofstream <> true arrrecord = split(myfile.readline, ",") ' make array of values in line on error goto skip 'there records don't want process: if arrrecord(1) <> "usa" call nosuchfunction if arrrecord(0) <= "12/31/2001" call nosuchfunction ' otherwise, run rest of code on record skip: loop
is there potential problem this? should use err.raise instead?
vbscript, unlike vba, doesn't have on error goto
. has on error resume next
.
however, case you're looking for, of exiting control flow early, can handled exit
statement. see this article microsoft scripting guys more details , examples.
if you're not in control flow looking exit, can hack creating 1 execute once:
do 'stuff if exit 'more stuff loop while false 'execute once, can left "exit do"
and while that's hack, i'm not sure it's worse trying use straight "goto" in first place. 1 can restructure logic clear 1 doing, without needing such inelegant constructs.
Comments
Post a Comment