#201061 - 2010-12-06 05:07 PM
Lost in quotes
|
KIXKicks
Starting to like KiXtart
Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
|
The following code doesn't work but I want to write it in the BP of Kix...
$LANDESKDBRSVULPATCHTRIM = Left($LANDESKDBRSVULPATCH, 6)
If $LANDESKDBRSVULPATCHTRIM = "winzip"
If $VISTA32 = "YES" Or $VISTA64 = "YES" Or $WIN7_32 = "YES" Or $WIN7_64 = "YES"
Shell '%COMSPEC% /C ' + $ELEVATESHELL + ' "\\"' + $LDSERVER + '"\LDLOGON\PATCH\"' + $LANDESKDBRSVULPATCH +
' INSTALLCMD="/notip /noqp /autoinstall" ADDDESKTOPICON=0 ADDSTARTMENU=0 DEFCOMPICK=LEGACY SHOW_WEBPAGE=0 USAGEPICK=USAGE_NO /QR'
Sleep 60
Else
Shell '%COMSPEC% /C "\\"' + $LDSERVER + '"\LDLOGON\PATCH\"' + $LANDESKDBRSVULPATCH +
' INSTALLCMD="/notip /noqp /autoinstall" ADDDESKTOPICON=0 ADDSTARTMENU=0 DEFCOMPICK=LEGACY SHOW_WEBPAGE=0 USAGEPICK=USAGE_NO /QR'
Sleep 5
EndIf
EndIf
The " are causing issues...I could drop them but is that within BP (Best Practices) of Kix?
Edited by Glenn Barnas (2010-12-18 01:37 PM) Edit Reason: broke 2 long lines
|
|
Top
|
|
|
|
#201062 - 2010-12-06 05:20 PM
Re: Lost in quotes
[Re: KIXKicks]
|
KIXKicks
Starting to like KiXtart
Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
|
I changed it to this:
$LANDESKDBRSVULPATCHTRIM = Left($LANDESKDBRSVULPATCH, 6)
If $LANDESKDBRSVULPATCHTRIM = "winzip"
If $VISTA32 = "YES" Or $VISTA64 = "YES" Or $WIN7_32 = "YES" Or $WIN7_64 = "YES"
Shell '%COMSPEC% /C ' + $ELEVATESHELL + ' "\\' + $LDSERVER + '\LDLOGON\PATCH\' + $LANDESKDBRSVULPATCH +
'" INSTALLCMD="/notip /noqp /autoinstall" ADDDESKTOPICON=0 ADDSTARTMENU=0 DEFCOMPICK=LEGACY SHOW_WEBPAGE=0 USAGEPICK=USAGE_NO /QR'
Sleep 60
Else
Shell '%COMSPEC% /C "\\' + $LDSERVER + '\LDLOGON\PATCH\' + $LANDESKDBRSVULPATCH +
'" INSTALLCMD="/notip /noqp /autoinstall" ADDDESKTOPICON=0 ADDSTARTMENU=0 DEFCOMPICK=LEGACY SHOW_WEBPAGE=0 USAGEPICK=USAGE_NO /QR'
Sleep 5
EndIf
EndIf
Edited by Glenn Barnas (2010-12-18 01:36 PM) Edit Reason: broke 2 long lines
|
|
Top
|
|
|
|
#201076 - 2010-12-06 06:27 PM
Re: Lost in quotes
[Re: Glenn Barnas]
|
KIXKicks
Starting to like KiXtart
Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
|
Thanks Allen/Glenn...
A side note, Glenn...I ran your SANITY and it while it found issues...it missed an issue with a line have two Ifs in it...
I don't have the exact code anymore but it was something like:
If $OSBit = "64 Bit" And $WIN7_64 = "Yes" If $OSBit = "32 Bit" And $WIN7_32 = "Yes"
? "Play KixGolf"
EndIf
Maybe it is acceptable to have two Ifs on one line, but I think it should at least flag it as a warning.
|
|
Top
|
|
|
|
#201090 - 2010-12-07 04:19 AM
Re: Lost in quotes
[Re: KIXKicks]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
|
We have a couple of Kix apps that are 20,000+ lines that KGen makes quick work of.. I use KGen for even the smallest of scripts.
KGen is a form of link-editor that locates all external UDFs and resolves dependencies. We start by putting all of our common, generic UDFs into a KixLib folder out on a share. That folder is defined in a KIXLIBPATH environment variable. When we create a script, it's "scriptname.txt" and we can reference any UDF in the library.. KGEN SCRIPTNAME examines the library, indexes which files hold what UDFs, and when a UDF reference is found in the script source, that file is added to the generated script file. KGen also checks for dependencies within the UDFs, insuring that all needed UDFs are included, and included only once.
Our larger projects break the script source into smaller modules, maintained in a project folder. SAMPLE.TXT contains only a descriptive header and variable declarations, 01_FRM.KXF contains KixForms form definitions, 01_BASE.KXF contains the base code, and an assortment of files following the ##_DESC.KXF naming format contain individual, project-specific UDFs or code blocks. This allows a project to be broken into smaller, managable chunks. All .KXF and .UDF files in the project folder are included in the generated output, along with any UDFs from the central library. One large project contains about 40 sub-files with 100-200 lines per file - easier to digest and manage than the 17,000 lines would be in a single file.
Once KGen completes the assembly, it creates a .GEN file with all external UDFs, including comments. KGen then creates the .KIX file, possibly tokenizing the .GEN, or simply stripping comments (hence the reason for the .GEN clear source). KGen runs Sanity against the completed script, generates an index of variables, a report of warnings, and a code-map that shows the structure of paired functions. This alone can save hours of troubleshooting by helping to locate most issues before you even execute the script.
A config file can control the default operation of KGen. Simply running KGEN will locate the file and generate the script, while KGEN ARG1 would employ a differnt set of parameters to, for example, generate the script, tokenize it with Kix version 4.53, and copy it to a target folder.
KGen is free to download from our web site - it's part of the KixDev package. The library of UDFs is included, and the latest copy of all of our UDFs is PostPrepped and copied to our web server every night at 20:00 EST.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#201211 - 2010-12-17 07:23 PM
Re: Lost in quotes
[Re: Glenn Barnas]
|
KIXKicks
Starting to like KiXtart
Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
|
Allen/Glenn
I still have this line that Sanity prefers I update to best practices...
Shell '%COMSPEC% /C %SYSTEMDRIVE%\NETWORK\KIX32.EXE S:\NETWORK\PATHMAN.KIX $$action=REM $$path=D:\PTC\Intralink 3.4\Bin"'
I guess I am unsure about the double $$...
This is my guess on how it should be, can you confirm?
Shell '%COMSPEC% /C %SYSTEMDRIVE%\NETWORK\KIX32.EXE S:\NETWORK\PATHMAN.KIX ' + $$action + '=REM "' + $$path + '=D:\PTC\Intralink 3.4\Bin"'
Edited by KIXKicks (2010-12-17 07:24 PM)
|
|
Top
|
|
|
|
#201227 - 2010-12-18 01:34 PM
Re: Lost in quotes
[Re: KIXKicks]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
|
Close - no need for double $ outside of quotes. There's also an odd double-quote there. Since you're calling a child Kix script and passing args, the whole thing can be in a string.
Again, try building your command as a string so you can display it during development and debugging:$Cmd = '%COMSPEC% /s %SYSTEMDRIVE%\NETWORK\KIX32.EXE '
$Cmd = $Cmd + 'S:\network\pathman.kix '
; sanity will complain about this $ - is OK, but MUST have NoVarsInStrings active
$Cmd = $Cmd + '$ACTION="REM" '
; Sanity won't complain about this line - the $ is replaced with Chr(36) outside the string
$Cmd = $Cmd + Chr(36) + 'PATH="DL\PTC\Intralink 3.4\Bin"'
; Should have WrapAtEOL turned on to properly see a long command line
; These can be removed or commented after testing.
'About to execute the following command:' ?
$Cmd ?
; Uncomment this line when the output string looks correct
; You can even copy the output line from the screen and paste it into
; a command prompt to verify that it works.
; Shell $Cmd By using "$Cmd = $Cmd + something", you can build the command bit by bit and easily see where quote or $ issues can arise. All of the lines are valid, but Sanity will complain about the first form because it sees a variable inside quotes. With NoVarsInStrings turned on in the beginning of your script, Kix won't interpret the variable, but Sanity doesn't know that (or recognize the NoVarsInStrings setting).
I'd suggest using the second format (Chr(36) + 'var=value') format as it will work regardless of the NoVarsInStrings setting, and won't trigger a Sanity warning.
Keep in mind that Sanity never issues errors! It warns you that it detected something that COULD be an issue. If you span a string across 2 or more lines - Sanity will warn about mismatched quotes - a heads up that this might not be what you intended. When I code with KGen, I closely examine the Sanity warnings and make note if which/how many I can safely ignore (usually in Execute statements or KixForms declarations) and make sure that I always get that number of warnings. The whole point it to have it find and eliminate the common, stupid errors that are just damn hard to find after staring at code for hours (or days).
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2375 anonymous users online.
|
|
|