#79297 - 2002-11-08 04:01 PM
Re: FOR EACH behavior
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
The "for each" does tell you it failed ... if you checked. And I requested that SPLIT("string","") return an array of single letters some time ago. code:
break on cls
;segment 1 dim $array[2] $array[0]='Array Entry 0' $array[1]='Array Entry 1' $array[2]='Array Entry 2' for each $element in $array ? 'Element = '+$element next ? "@error @serror"
; segment 2 dim $array $array='String Entry 0' for each $element in $array ? 'Element = '+$element next ? "@error @serror"
[ 08. November 2002, 16:08: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#79298 - 2002-11-08 04:32 PM
Re: FOR EACH behavior
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
but @error & @serror are not reset to zero when "For each" executes correctly. If there is not an intervening function that sets @Error to zero the same "-1 Expected an object reference. [-1/FFFFFFFF]" error is repeated. [ 08. November 2002, 16:33: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#79300 - 2002-11-11 01:52 PM
Re: FOR EACH behavior
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Lonkero, for me it was just laziness. The ease of copy/paste without fear of trouble for this little test.
|
|
Top
|
|
|
|
#79301 - 2005-10-13 05:47 PM
Re: FOR EACH behavior
|
Doofus
Lurker
Registered: 2005-10-13
Posts: 1
|
My problem is that even if I DIM the array (DIM $array[10]), if I populate it with only one entry ($array = "element1"), I still encounter the same problems.
The only good workaround I've come up with is to tag a blank element onto the array ($array = "element1", ""), then wrap the contents of the FOR EACH with an IF:
Code:
FOR EACH $element IN $array IF $element ? $element ENDIF NEXT
Which is pretty ugly and a hassle.....
|
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 671 anonymous users online.
|
|
|