Page 1 of 1 1
Topic Options
#201061 - 2010-12-06 05:07 PM Lost in quotes
KIXKicks Offline
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...

 Code:
$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 Offline
Starting to like KiXtart

Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
I changed it to this:

 Code:
$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
#201064 - 2010-12-06 05:29 PM Re: Lost in quotes [Re: KIXKicks]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
The second one looks right... is it working now?
_________________________
(... better days ahead)

Top
#201067 - 2010-12-06 05:36 PM Re: Lost in quotes [Re: KIXKicks]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Trying to create Shell commands on a single line is bad form.. Using something like this makes it more managable and can provide a debugging message as well:
 Code:
$Cmd = '%COMSPEC% /c ' ; note trailing SPACE
$Cmd = $Cmd + '"\\' + $LDSERVER + '\LDLOGON\PATCH\' + $LANDESKDBRSVULPATCH + '" '
$Cmd = $Cmd + 'INSTALLCMD="/notip /noqp /autoinstall" ADDDESKTOPICON=0 '
$Cmd = $Cmd + 'ADDSTARTMENU=0 DEFCOMPICK=LEGACY SHOW_WEBPAGE=0 USAGEPICK=USAGE_NO /QR'
'DEBUG - About to run: ' @CRLF $Cmd @CRLF
Shell $Cmd
'DEBUG - Result: ' @SERROR @CRLF
Of course, this is only half of your logic, but you can see that each line contains only one embedded double-quote pair. This makes it easier to keep track of open/close quotes. Using the SANITY UDF or my KGen tool will help as well. Also note that each line except the last contains a space.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#201076 - 2010-12-06 06:27 PM Re: Lost in quotes [Re: Glenn Barnas]
KIXKicks Offline
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:

 Code:
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
#201078 - 2010-12-06 06:31 PM Re: Lost in quotes [Re: KIXKicks]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
For every IF there should be an corresponding ENDIF...

I can tell you, how you have that line is definitely NOT best practice.

[edit
Oh... you were pointing out Sanity missing this... sorry.]


Edited by Allen (2010-12-06 06:33 PM)
_________________________
(... better days ahead)

Top
#201082 - 2010-12-06 09:22 PM Re: Lost in quotes [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
The actual warning that Sanity should throw is the missing second EndIf. The statement is legal, just fugly (and definately not good practice).

I'll look at why Sanity missed the missing EndIf. It's possible that I never anticipated that.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#201083 - 2010-12-06 09:32 PM Re: Lost in quotes [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Yep - Sanity won't find multiple paired statements per line. It assumes that each statement pair will be on a separate line. I don't have an easy way to change this logic without a full rewrite - and that's unlikely. You'll just have to use a modicum of good practices. \:D

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#201086 - 2010-12-06 10:19 PM Re: Lost in quotes [Re: Glenn Barnas]
KIXKicks Offline
Starting to like KiXtart

Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
OK, a copy and paste error caused about 3 hours of searching for this...is there a better way to troubleshoot errors for 12,000 line kix script?
Top
#201090 - 2010-12-07 04:19 AM Re: Lost in quotes [Re: KIXKicks]
Glenn Barnas Administrator Offline
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! \:D

Top
#201211 - 2010-12-17 07:23 PM Re: Lost in quotes [Re: Glenn Barnas]
KIXKicks Offline
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...

 Code:
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?

 Code:
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 Administrator Offline
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:
 Code:
$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! \:D

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2870 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.035 seconds in which 0.014 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