Page 3 of 3 <123
Topic Options
#73414 - 2003-02-27 12:52 AM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
not quite sure ... easy to proof though ... gimme an hour for lunch and coffee [Wink]
_________________________



Top
#73415 - 2003-02-26 03:44 PM Re: RE: arraycomp () UDF by Darren
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the hour has gone...
_________________________
!

download KiXnet

Top
#73416 - 2003-02-26 03:51 PM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
oh ... thanx for waking Riff *yaawwwn
_________________________



Top
#73417 - 2003-02-26 03:52 PM Re: RE: arraycomp () UDF by Darren
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Variables should always be DIMmed regardless of whether 'Option Explicit' is used or not. This way they get assigned the correct scope.
_________________________
There are two types of vessels, submarines and targets.

Top
#73418 - 2003-02-26 03:54 PM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
ok ... is this enough ?



break on

$a = 1,2,3,4

$ = test($a)

"back in main : " ?
"$$e = " + $e ?

get $


function test($a)
    "in udf :" ?
    for each $e in $a
        "$$e = " + $e ?
    next
    "end of udf" ? ?
endfunction



{even if "global $e" statement at the start of script}

[ 26. February 2003, 15:57: Message edited by: jpols ]
_________________________



Top
#73419 - 2003-02-26 03:58 PM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Jens ?

Contradict you .. see above
_________________________



Top
#73420 - 2003-02-26 04:05 PM Re: RE: arraycomp () UDF by Darren
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
No contradiction. As I said 'should' in order to get the scopes correct. However, if you like to do it this way, go ahead. I just prefer to use 'Explicit' as it forces me to code more precisely and it also double-checks for errors in the variable name,s e.g. spelling errors.
_________________________
There are two types of vessels, submarines and targets.

Top
#73421 - 2003-02-26 04:06 PM Re: RE: arraycomp () UDF by Darren
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh, thanks.
sort of autodim!

mm... could this be used with explicit option in golfing... mm...
_________________________
!

download KiXnet

Top
#73422 - 2003-02-26 04:09 PM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
On the other side I must assume that the 'for each' construct sets it's own scope oppposite to 'for .. next' loops that return a value from the udf for $e if $e is set global ...

A small but significant difference , no ?
_________________________



Top
#73423 - 2003-02-26 04:12 PM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
damn language ... I meant 'I contradict You ... '
I don't wanted to say that you contrdicted yourself [Roll Eyes]

Sorry
_________________________



Top
#73424 - 2003-02-26 04:17 PM Re: RE: arraycomp () UDF by Darren
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Run the thing with explicit=on [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#73425 - 2003-02-26 04:24 PM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hell , NO !

I won't restrict myself that much [Eek!] [Eek!] [Eek!]

Nothing against you but I think that you are the only one around here that is masochistic enough to use it [Razz]
_________________________



Top
#73426 - 2003-02-26 04:32 PM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
On the other side this confuses me a bit :



break on
$ = setoption("Explicit","on")
Global $a$e

$a = 1,2,3,4

$ = test($a)

"back in main : " ?
"$$e = " + $e ?

get $


function test($a)
    "in udf :" ?
    for each $e in $a
        "$$e = " + $e ?
    next
    "end of udf" ? ?
endfunction



If i Ergo correctly the local forced scope in 'for each' loops weighs more than Global scope

[ 26. February 2003, 16:38: Message edited by: jpols ]
_________________________



Top
#73427 - 2003-02-26 05:22 PM Re: RE: arraycomp () UDF by Darren
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, what about:
code:
$ = setoption("Explicit","on")
Global $a

$a = 1,2,3,4
$ = test($a)

get $


function test($a)
"in udf :" ?
for each $a in $a
"$$a = " + $a ?
next
"end of udf" ? ?
endfunction

_________________________
!

download KiXnet

Top
#73428 - 2003-02-27 09:21 AM Re: RE: arraycomp () UDF by Darren
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Weirdo !!!

nice feature, but advanced users only, eh ?
_________________________



Top
#73429 - 2003-02-27 09:29 AM Re: RE: arraycomp () UDF by Darren
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that is the "thingie" that was used in registry-write GOLF.

got many strokes of [Wink]
_________________________
!

download KiXnet

Top
#73430 - 2003-02-27 09:17 PM Re: RE: arraycomp () UDF by Darren
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
Updated the function.

Had a read in the manual and it looks like the varable is only valid within the script segment,this I feel applies to a function, therefore I will leave it as is should anyone feel different?

Bye
_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
Page 3 of 3 <123


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 202 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.072 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org