Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You have an extreme duplication of code.
You may want to consider something like the sample for "GLA" below. I have not analyzed the level of duplication between the subroutines GLA, GRA, PAN , and PRI. You should strive to reduce the duplication. Doing so will make maitenance much easier. code:
:GLA ? "USERS NAME IS " + @fullname ? "MACHINE NAME IS " + @wksta ? "IP ADDRESS IS " + @ipaddress0 ? "CPU IS " + @cpu ? "OPERATING SYSTEM IS " + @producttype ? "SERVICE PACK IS " + @csd ? ? "ERRORS ARE " +@error " WHICH MEANS " + @serror ? If @INWIN=1 If InGroup("IT-PRINT1-GRP") $null=AddPrinterConnection("\\Gfclnt04\CITSL4C1") $null=AddPrinterConnection("\\Gfclnt04\CITSLJ03") $null=AddPrinterConnection("\\Gfclnt04\AITSL502") $null=AddPrinterConnection("\\Gfclnt04\AITSL501") $null=SetDefaultPrinter("\\Gfclnt04\AITSL502") ? "Added printer connection.........." ENDIF
IF InGroup("IT-PRINT2_GRP") $null=AddPrinterConnection("\\Gfclnt04\CITSL4C1") $null=AddPrinterConnection("\\Gfclnt04\CITSLJ03") $null=AddPrinterConnection("\\Gfclnt04\AITSL502") $null=AddPrinterConnection("\\Gfclnt04\AITSL501") $null=SetDefaultPrinter("\\Gfclnt04\AITSL501") ? "Added printer connection.........." ENDIF If InGroup("checkline-grp") MapDrive("H:","GCKLNT01","wineftnt") Endif IF InGroup("MOVED_USERS") SHELL 'SUBST U: /D ' SHELL 'SUBST U: "\\gfclnt03\users\%username%" ' ENDIF
IF InGroup("RESEARCH-GRP") MapDrive("Z:","GAPPNT02","RESEARCH") MapDrive("P:","GMSHNT01","Public") ENDIF Else ; Win95 IF InGroup("MOVED_USERS") MapDrive("U:","gfclnt03","users") CD U:\users\@userid ENDIF Endif IF InGroup("Scottish Magazines") MapDrive("N:","GAPPNT04","ScottishMagazines") ENDIF
IF InGroup("Solus-Grp") MapDrive("Q:","GAPPNT04","SolusBookingSystem") ENDIF
IF InGroup("ADQUICK-GRP") MapDrive("G:","GTPSNT01","Quick") ENDIF
IF InGroup("CUSTSERV-GRP") MapDrive("R:","GAPPNT02","CSDBase") ENDIF
IF InGroup("SATEAM-GRP") MapDrive("X:","GMSHNT01","TECH_SUPPORT") ENDIF
IF InGroup("MOVE-GRP") MapDrive("J:","GFCLNT04","CentralServices") ENDIF
IF InGroup("CENTRALS-GRP") ; MapDrive("J:","GFCLNT04","CentralServices") ENDIF
IF InGroup("GPNCENTRALS-GRP") ; MapDrive("N:","QCLUNT01","CentralServices") ENDIF
IF InGroup("BROADCAS-GRP") MapDrive("K:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("BROADDIST-GRP") MapDrive("I:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("GPNBROADCAST-GRP") MapDrive("O:","QCLUNT01","Broadcasting") ENDIF
IF InGroup("PUBLISHI-GRP") MapDrive("L:","GFCLNT04","Publishing") ENDIF
IF InGroup("S1-GROUP") MapDrive("V:","GAPPNT03","S1") USE V: "\\GAPPNT03\S1" ENDIF
IF InGroup("COGNOS-USERS") MapDrive("Y:","GTPSNT01","cognos") ENDIF
IF InGroup("SUNDAY-GRP") MapDrive("S:","GMSHNT01","Sunday") ENDIF
IF InGroup("STE-GRP") MapDrive("M:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("MARKETIN-GRP") MapDrive("T:","GAPPNT05","Despatch_DB") ENDIF
IF InGroup("MARKETDB-GRP") MapDrive("S:","GAPPNT05","NSDOCS") ENDIF
IF InGroup("MAGASUBS-GRP") MapDrive("F:","GAPPNT02","MAGAZINES") ENDIF
IF InGroup("GPNPUBLIC-GRP") ; MapDrive("Q:","QCLUNT01","Public") MapDrive("P:","GMSHNT01","Public") ENDIF RETURN
;-------------------------------------------------------------------------------------------------- Function MapDrive($Drive, $Server, $Share) Dim $Drive, $Server, $Share Color c+/n If $Drive<>"" and $Server<>"" and $Share<>"" $LogText="Connecting $Drive to \\$Server\$Share" ? $LogText USE $Drive /Delete /Persistent USE $Drive "\\$Server\$Share" If @error=0 color g+/n $x=" - Success" "$x" Else color r+/n $x=" - Failed: Error @error" "$x" $ErrorState=1 Endif WriteLog ($LogText + $x) Color w+/n Else WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'") Endif Endfunction ;-------------------------------------------------------------------------------------------------- Function WriteLog($text) dim $RC, $text, $LogFile, $Filehandle $Filehandle = 1 $LogFile = "%temp%\logon.log" $RC=Writeline ($Filehandle, "@Date @Time - $Text" + Chr(13) + Chr(10)) if $RC<0 $RC=Close ($Filehandle) $RC=Open ($Filehandle, $LogFile, 5) Select Case $RC=-1 $RC=MessageBox ("Invalid file name ($LogFile) specified for log file.","Logon Script Error",48) Case $RC=0 WriteLog ($Text) Case $RC=>0 $RC=MessageBox ("Error($RC) while attempting to open log file ($LogFile).","Logon Script Error",48) Endselect Endif EndFunction
|