Page 1 of 1 1
Topic Options
#193432 - 2009-04-15 09:49 AM Can't see the error
Ashpoint Offline
Starting to like KiXtart

Registered: 1999-08-27
Posts: 192
Loc: Sydney, NSW, Australia
I've been staring at this too long and can't see the error.

Invalid function PrintMaker in the line of code PrintMaker($_Pr)

I've used this functionality elsewhere without a problem - just this site. I ensured that the newest version of KiX is installed.

I know I'm going to be embarrassed that I can't see the error!

 Code:
;============================================================
; KIXTART.KIX
;
; By Michael Rychter - Ashpoint Pty Limited Ph: 0418 229 934
;
; First created on 21 December 1999
;============================================================

SETTIME "\\HOPEWOODSBS"
SETCONSOLE("HIDE")

DIM $_Pr, $RC, $UserID, $HomeServer, $CoGroup, $SQLDrive, $NetWorkDrive, $CDDrive, $SQLShare, $NetWorkShare, $CDShare

$UserId=@userid
$HomeServer="HOPEWOODSBS"
;*********************** BgInfo *************************************
$RC = "BgInfo.exe"
IF EXIST(%WinDir% + "\" + $RC) = 0
  COPY @LSERVER + "\Netlogon\" + $RC %WinDir% + "\" + $RC
ENDIF

$RC = "Ashpoint.bgi"
IF EXIST(%WinDir% + "\" +$RC) = 0
  COPY @LSERVER + "\Netlogon\" + $RC %WinDir% + "\" + $RC
ENDIF
RUN %WinDir% + "\BGInfo.exe " +  %WinDir% + "\Ashpoint.bgi /taskbar /NoLicPrompt"
;********************************************************************

$SQLDrive     = "S:"
$NetWorkDrive = "Z:"
$CDDrive      = "Y:"

$SQLShare     = "\\$HomeServer\SQLBackups"
$NetWorkShare = "\\$HomeServer\NetWork"
$CDShare      = "\\$HomeServer\CD"

USE $SQLDrive     /DELETE
USE $NetWorkDrive /DELETE
USE $CDDrive      /DELETE

USE $NetWorkDrive $NetWorkShare
USE $CDDrive $CDShare

IF $UserID = "SBeavon"
  USE $SQLDrive $SQLShare
ENDIF

;=================== Printer Settings =================================

$_Pr = "\\HOPEWOODSBS\HP4100"
PrintMaker($_Pr)
$_Pr = "\\HOPEWOODSBS\HP4250"
PrintMaker($_Pr)
$_Pr = "\\HOPEWOODSBS\HP4250_Spare"
PrintMaker($_Pr)
$_Pr = "\\HOPEWOODSBS\ShopLaser"
PrintMaker($_Pr)
$_Pr = "\\HOPEWOODSBS\ServerFax"
PrintMaker($_Pr)
IF @WKSta<>"HP_June08_01)
  $_Pr = "\\HP_June08_01\HL2040"
  PrintMaker($_Pr)
ENDIF

;$Nul = ADDPRINTERCONNECTION("\\HOPEWOODSBS\HP4100")
;$Nul = ADDPRINTERCONNECTION("\\HOPEWOODSBS\HP4250")
;$Nul = ADDPRINTERCONNECTION("\\HOPEWOODSBS\HP4250_Spare")
;$Nul = ADDPRINTERCONNECTION("\\HOPEWOODSBS\ShopLaser")
;$Nul = ADDPRINTERCONNECTION("\\HOPEWOODSBS\ServerFax")

;SETDEFAULTPRINTER("HP4250")

;=================== Printer Announcements =============================

$Key = "HKCU\Printers\Settings"
$RK= KeyExist($Key)
IF @ERROR <> 0
  ADDKEY($Key)
  WriteValue($Key,"EnableBalloonNotificationsLocal","0","REG_DWORD")
  WriteValue($Key,"EnableBalloonNotificationsRemote","0","REG_DWORD")
ENDIF


COOKIE1
:end
EXIT 0



;============================ FUNCTION PriMapState ========================

;FUNCTION	PriMapState 
; 
;AUTHOR		Lonkero (Jooel.Nieminen@gwspikval.com) 
; 
;ACTION		Checks for existent networkprinter connection 
; 
;VERSION	1.1.1 
; 
;CHANGES	1.1.1	- 01. november 2003 
;		 Fixed buggie descriped in: 
;		 http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=008079 
;		1.1	- 02. July 2002 
;		 added support for win9x 
;		1.0	- 01. July 2002 
;		 initial release 
; 
;SYNTAX		PriMapState(PRINTER) 
; 
;PARAMETERS	PRINTER 
;		 to be checked Printer's name 
; 
;RETURNS	1 if printer connected 
;		2 if printer is default 
;		nothing if not connected 
; 
;REMARKS	code for w9x adapted from BrianTX 
; 
;DEPENDENCIES	none 
; 
;EXAMPLE 
;		if not PriMapState('\\server\printer1') 
;		 "printer1 not connected!" 
;	        endif 
; 
;CODE 

function PriMapState($_Pri)
if @inwin=1
 if len(readvalue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices",$_Pri))
  if split(readvalue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0]=$_Pri
   $PriMapState=2
  else
   $PriMapState=1
  endif
 endif
else
 dim $_Root,$_C,$_C2 $_Root="HKLM\System\CurrentControlSet\control\Print\Printers"
 for $_C=0 to 259
  $_C2=enumkey($_Root,$_C)
  If instr(READVALUE($_Root+"\"+$_C2,"Port"),$_Pri)
   If instr(READPROFILESTRING("%windir%\win.ini","windows","device"),$_Pri)
    $PriMapState = 2
   Else
    $PriMapState = 1
   Endif
  Endif
  if $_C2=259 $_C=$_C2 endif
 next
endif
endfunction


;============================ FUNCTION PrintMaker ============================

FUNCTION PrintMaker($_pr)
  IF PriMapState($_pr) = 0
    $null = ADDPRINTERCONNECTION($_Pr)
  ENDIF
ENDFUNCTION

;============================ FUNCTION EnumProcess ===========================

;DO NOT change anything below this line!! This UDF is ready for use as it is.
Function EnumProcess($exe, optional $terminate, optional $Computer)
Dim $winmgmts, $ExecQuery, $Process, $id
If NOT $computer
  $computer=@wksta
EndIf
$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
Select
  Case Val($exe)>0
    $ExecQuery="select * from Win32_Process where ProcessId='$exe'"
    $GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
    For Each $Process in $GetObject
      If $terminate
        $=$Process.Terminate
      EndIf
      $EnumProcess = $Process.name
    Next
    $GetObject=''
    Case VarType($exe)=8
      $ExecQuery="select * from Win32_Process where Name='$exe'"
      $GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
      For Each $Process in $GetObject
        If $terminate
          $=$Process.Terminate
        EndIf
        $id=$Process.ProcessId
        $EnumProcess = "$Id" + "|" + "$EnumProcess"
      Next
      $EnumProcess=Left($EnumProcess,Len($EnumProcess)-1)
      $GetObject=''
    Case 1
       Exit 1
  EndSelect
EndFunction

;============================ FUNCTION Screen Resolution ===========================
Function GetScreenRes()
  Dim $Dev,$Idx,$RKey,$ScreenXRes,$ScreenYRes,$SType
  $GetScreenRes = ''
  If @InWin = 1 
    If Split(@ProductType)[1] <> "NT"
      $Dev = Split('' + WMIQuery("VideoModeDescription","Win32_VideoController"))
      If UBound($Dev) > 1
        $GetScreenRes = $Dev[0] + "," + $Dev[2]
      EndIf
    Else
      $RKey="HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services"
      $Dev = "\Device0"
      If KeyExist($RKey)
        $Idx = 0
        Do
          $SType = EnumKey($RKey,$Idx)
          If @Error = 0 And $SType <> "VgaSave"
              $ScreenXRes = '' + ReadValue($RKey + "\" + $SType + $Dev,"DefaultSettings.XResolution")
              $ScreenYRes = '' + ReadValue($RKey + "\" + $SType + $Dev,"DefaultSettings.YResolution")
          Else
            $Idx = $Idx + 1
          EndIf
        Until @Error Or $ScreenXRes
        If $ScreenXRes
          $GetScreenRes = $ScreenXRes + ',' + $ScreenYRes
        EndIf
      EndIf
    EndIf
  Else
    $RKey="HKLM\Config\0001\Display\Settings"
    If KeyExist($RKey)
      $GetScreenRes = ReadValue($RKey,"Resolution")
    EndIf
  EndIf
EndFunction
 
; For easier cut'n paste, here is the code stolen from Radimus
; Explanation for WMIQuery(): Look in the link under dependencies
FUNCTION WMIQuery($what,$where, optional $computer)
  dim $strQuery, $objEnumerator, $value
  if not $computer  $computer="@WKSTA"  endif
  $strQuery = "Select $what From $where"
  $SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer")
  $objEnumerator = $SystemSet.ExecQuery($strQuery)
  For Each $objInstance in $objEnumerator
    If @Error = 0 and $objInstance <> ""
      $=execute("$$value = $$objInstance.$what")
      $WMIQuery="$value"+"|"+"$WMIQuery"
      EndIf
    Next
  $WMIQuery=left($WMIQuery,len($WMIQuery)-1)
  exit @error
ENDFUNCTION


Top
#193435 - 2009-04-15 12:02 PM Re: Can't see the error [Re: Ashpoint]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Prepare for the red face...

You are missing a quote character on this line:
 Code:
IF @WKSta<>"HP_June08_01)


[edit]And you've got an extraneous closing parenthesis.[/edit]

Top
#193437 - 2009-04-15 12:14 PM Re: Can't see the error [Re: Richard H.]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4350
Loc: New Jersey
Which Sanity() would have caught for ya! ;\)

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

Top
#193447 - 2009-04-15 11:38 PM Re: Can't see the error [Re: Glenn Barnas]
Ashpoint Offline
Starting to like KiXtart

Registered: 1999-08-27
Posts: 192
Loc: Sydney, NSW, Australia
Happy to be red faced - at least it is now fixed.

Strange thing is that the quotes error (which I didn't see) was several lines past where the error was reported.

As per my past practice, I will make a donation to the Australian National Breast Cancer Foundation for the assistance provided by the memebers of the KiX community.

Best regards to all from Down Under

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 315 anonymous users online.
Newest Members
Praveer, Ollero, rayyo, Foxlicht, DonChild
17742 Registered Users

Generated in 0.03 seconds in which 0.012 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