|
|
|||||||
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. |
||||||||
|
|
|||||||
the use command doesn't return a 1 or 0...I'd bet its the UDF doing it... put your $= in front of the UDF. |
||||||||
|
|
|||||||
Seems like a good point but when I tried it I still get a whole lot of 1's in the output... |
||||||||
|
|
|||||||
Functions (and most UDFs) return error codes... so in order to silence them you will need to send that output to a variable... Check out the FAQ Section... there is a whole topic dedicated to the subject. |
||||||||
|
|
|||||||
Is the UDF one from this forum or from somewhere else? You can post it if you like... and just for any clarification... $=functionname($var) or $nul=functionname($var) will supress the output (the 0s or 1s) and put the output into a variable called $ or $nul... or for that matter whatever you want to call it. The reason you get an error when you put $= in front of the use is because use is a command, not a function. If you checkout the manual, you will see that the commands, and functions are separated into different sections. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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) |
||||||||
|
|
|||||||
I would like to first suggest that there are at least 2 different Mapdrive UDFs in the UDF Forum... you might check those out, as there is no real need to reinvent the wheel. But the problems and the 1's you are seeing are actually in your if statements: Replace this: Code: If $Drive NOT "" AND $Share NOT "" with this: Code: if $drive and $share But if you really want to use the "Not"s, try this... Code: If not $Drive="" AND not $Share="" As a side note, I had to laugh... I wonder if you come from a batch coding background... I was accused of liking "Not" when I first start posting here, and it was because all I had ever used was bat files. |
||||||||
|
|
|||||||
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) |
||||||||
|
|
|||||||
Actually, $drive and $share are both required parameters of your udf... so really the first "if" is redundant... because kixtart will error out if you do not supply the proper parameters... |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
Quote: 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") ? Gives: Quote: |
||||||||
|
|
|||||||
And read the FAQ Forum with regards to suppressing 0 and 1 outputs. |