Re: Returning the var type based on content of object
- Posted by znorq2 May 18, 2009
- 831 views
There is one question; Why doesn't this fail when there is a string format with only one character, i.e. "x"...? The for "cnt = 2 to..." shouldn't be able to continue, as there is no second element in a "x" string..
The for loop never executes, so execution jumps right to the final return statement.
Matt
Matt,
So, counting downards without the for's "by -1" parameter, results in the code block not being executed at all? I guess that is evaluated before the for loop starts the execution?
Kenneth / ZNorQ Learing something new every day..
Sort of...
Given this code ...
for cnt = 2 to length(oObject) do if sequence(oObject[cnt]) then return 'N' end if end for
The body of the 'for' loop is only executed when 'cnt' is less than or equal to the length of 'oObject'. So if 'cnt' starts at 2 and the length is 1, then the body will not execute because 'cnt' is not less than or equal to the length.
It has nothing to with counting up or down.
Ok. I just realized how many if-then blocks of code I could have omitted using this technique. Anyway, great help from the both of you - thanks.
Kenneth / ZNorQ