#148521 - 2005-09-27 05:24 AM
Hiding Return Values
|
Skorpion
Fresh Scripter
Registered: 2005-09-27
Posts: 11
|
Hey all,
I've got a logon script and in there I've got a UDF to map drives. The only problem is that with the Use command it returns 1's everytime it maps a drive...
This is the statement: Code:
Use $Drive "\\" + $Server + "\" + $Share
I've also tried adding a $ = in front of the statement but I then get an "Error in expression".
Has anyone got any ideas how I would get around this? I can post the UDF if required.
|
|
Top
|
|
|
|
#148523 - 2005-09-27 05:43 AM
Re: Hiding Return Values
|
Skorpion
Fresh Scripter
Registered: 2005-09-27
Posts: 11
|
Seems like a good point but when I tried it I still get a whole lot of 1's in the output...
|
|
Top
|
|
|
|
#148526 - 2005-09-27 06:10 AM
Re: Hiding Return Values
|
Skorpion
Fresh Scripter
Registered: 2005-09-27
Posts: 11
|
Tried that but nothing - So now I've got $RV = MapDrive() but I still get 1's...
I've tried it in debug mode and it definately appears to be when using the "Use" command that it's outputting the 1's if that helps
|
|
Top
|
|
|
|
#148527 - 2005-09-27 06:20 AM
Re: Hiding Return Values
|
Skorpion
Fresh Scripter
Registered: 2005-09-27
Posts: 11
|
Here's the UDF - I created it today (I know, not the tidiest - still got to clean it up a bit)
Code:
Function MapDrive($Drive, $Share, Optional $Server) If $Drive NOT "" AND $Share NOT "" Use $Drive /DELETE If $Server NOT "" Use $Drive "\\" + $Server + "\" + $Share Else ; Used for \\server\share (i.e. the users home folder from AD) Use $Drive $Share EndIf
If @ERROR = 0 OR @ERROR = 1202 Color w/n ? $Drive + " drive - " + $Share + " on " + $FileServer + " - Attached" Else Color r+/n ? "Cannot connect to " + $Drive + "!! " + @SERROR EndIf EndIf
Color w/n EndFunction
|
|
Top
|
|
|
|
#148529 - 2005-09-27 06:57 AM
Re: Hiding Return Values
|
Skorpion
Fresh Scripter
Registered: 2005-09-27
Posts: 11
|
No I'm actually a PHP Developer :-)
I prefer NOT to <> as it's clearer for non-programmers (or non-scripters) to understand what it's doing...
You're a legend :-) Worked perfectly... love KiX but don't like it's conditional statements, like if() {} ! etc syntax (but then again I would, programmed in PHP, Java and C)
|
|
Top
|
|
|
|
#148531 - 2005-09-27 11:24 AM
Re: Hiding Return Values
|
Skorpion
Fresh Scripter
Registered: 2005-09-27
Posts: 11
|
But what if you supply an argument that exists but has no value? then the "if" statement is not redundant... but I may be wrong, i'm not 100% up to how KiX would handle this situation.
|
|
Top
|
|
|
|
#148532 - 2005-09-27 02:31 PM
Re: Hiding Return Values
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
I prefer NOT to <> as it's clearer for non-programmers (or non-scripters) to understand what it's doing...
Careful, "NOT" and "<>" do completely different things. Don't fall into the trap of thinking that they are interchangeable. You can often use them to get the same result, much as you can use a hammer to drive a screw.
Be very careful when using things like NOT, also when using the item value for boolean truths. All variables in KiXtart are variants, and KiXtart will convert between sub-types silently when it has to.
This can mean that your numeric values can be easily cast to string variants. This catches people out because a string with a value of "0" is actually TRUE, whereas a number with a value of 0 is FALSE. However a zero length string is FALSE.
The most common example of confusion is when reading registry values, which are always returned as strings regardless of registry type.
For example: Code:
"0 is " IIf(0,"TRUE","FALSE") ? "1 is " IIf(1,"TRUE","FALSE") ? "'0' is " IIf('0',"TRUE","FALSE") ? "'1' is " IIf('1',"TRUE","FALSE") ? "'' is " IIf('',"TRUE","FALSE") ?
Gives:
Quote:
0 is FALSE 1 is TRUE '0' is TRUE '1' is TRUE '' is FALSE
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1607 anonymous users online.
|
|
|