#169774 - 2006-10-23 04:33 PM
Probplem with IIF() Function?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Hi, maybe this is something I am doing stupid!
I am using the IIF() function as follows...
Code:
IIf(MAPDRIVE($sDriveMap,,1) == 0, WriteAndDisplay("[OK]"), WriteAndDisplay("[WARNING] " + @SERROR))
However, if MAPDRIVE succeeds IIF seems to execute both WriteAndDisplay functions. However if I take the functions out so, i.e. "[OK]" is left and MAPDRIVE succeeds only the "[OK]" is executed hence written to the screen.
Any ideas on what is causeing this?
Thanks.
Lee.
|
Top
|
|
|
|
#169775 - 2006-10-23 04:40 PM
Re: Probplem with IIF() Function?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Could it be because WriteAndDisplay doesn't return anything?
|
Top
|
|
|
|
#169780 - 2006-10-23 04:55 PM
Re: Probplem with IIF() Function?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Sorry, yes I know I can do that but I was wondering why IIF doesn't work?
L.
|
Top
|
|
|
|
#169781 - 2006-10-23 04:56 PM
Re: Probplem with IIF() Function?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Quote:
...man... just alter the WriteAndDisplay to give a output ;P this just proves that I shouldn't 'open' my keyboard before I've thought things thro ;P
but shouldn't IIF just return an empty string if there is nothing to return?
|
Top
|
|
|
|
#169783 - 2006-10-23 05:01 PM
Re: Probplem with IIF() Function?
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Code:
If MAPDRIVE('z','\\SERVER\share',1) WriteAndDisplay("[WARNING] " + @SERROR) Else WriteAndDisplay("[OK]") EndIf
|
Top
|
|
|
|
#169784 - 2006-10-23 05:01 PM
Re: Probplem with IIF() Function?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
hmm ok but surely IIF shouldn't execute both sections?
|
Top
|
|
|
|
#169786 - 2006-10-23 05:03 PM
Re: Probplem with IIF() Function?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Quote:
LOL. Golfing showed it’s ugly face once more
Am I missing something?
|
Top
|
|
|
|
#169787 - 2006-10-23 05:06 PM
Re: Probplem with IIF() Function?
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
hmm ok but surely IIF shouldn't execute both sections?
Yes it should.
You can only pass simple parameters to the IIF() function, so the result of the expressions (your functions and the conditional part) *have* to be resolved before IIF() is called.
To do anything different would require you to be able to pass function references, which is not possible in KiXtart.
|
Top
|
|
|
|
#169788 - 2006-10-23 05:07 PM
Re: Probplem with IIF() Function?
|
Björn
Korg Regular
Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
|
Yes, check out all the kixtart-golfing series in the ot-forum you could always check out the learning-series if you wish too (under scripts and examples I think). But, now we know why it didn't really work out the way it was supposed to. back to topic - I do have to advise you to alter the WriteAndDisplay to throw ya an error-code tho...
|
Top
|
|
|
|
#169789 - 2006-10-23 05:13 PM
Re: Probplem with IIF() Function?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Ah cool that explains it. I was likening it with the behaviour of the C++ IIF function.
|
Top
|
|
|
|
#169791 - 2006-10-23 05:41 PM
Re: Probplem with IIF() Function?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
cool
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 557 anonymous users online.
|
|
|