#91997 - 2003-05-09 07:53 PM
Uh, Nevermind.....
|
Rocco Capra
Hey THIS is FUN
   
Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
|
Not sure if this is in the right forum since it is a 'kixform' I'll stick it in here. Feel free to move it though.
Here's my problem, I have a form that submits some info to our helpdesk via blat. It all works great until I wanted to 'attach' a file. I use the FileOpenDialog to get the path and file. Then try to tell blat to attach that file. It fails with "The system cannot find the file specified". If I type in the the same thing that the FileOpenDialog returns in the script itself, it works just fine. There seems to be a problem with the way I build my blat $CMD and it's interpretation of the variable.
Here is the script in whole...
code:
BREAK ON GLOBAL $AttachF IF(Exist('%TEMP%\output.tmp')) DEL '%TEMP%\output.tmp' ENDIF $OUTPUT='%TEMP%\output.tmp' ;---------------------------------------------------------------------------------------- $Form=CreateObject('Kixtart.Form') $Form.Caption='ITSoft - HelpDesk!' $Form.Width=455 $Form.Height=445 $Form.SysMenu=1 $Form.BackColor=204,204,204 $Form.FontName='Courier' $Form.FontSize=10 $Form.Center ;---------------------------------------------------------------------------------------- $Logo=$Form.Image(@SCRIPTDIR+'\helpdesk_title.bmp',0,0,450,80) $Logo.Border=0 ;---------------------------------------------------------------------------------------- $Frame1=$Form.Frame('Location Info',5,82,440,145) $Label1=$Form.Label('Site Location (Division)* :',15,100) $Label2=$Form.Label('Phone Number (Extention)* :',15,125) $Label3=$Form.Label('Location of Computer (Cube#)*:',15,150) $Label4=$Form.Label('Your Name (Fisrt Last)* :',15,175) $Label5=$Form.Label('Jack # of Computer/Phone :',15,200) $SiteT=$Form.TextBox('',255,100,182,20) $PhonT=$Form.TextBox('',255,123,182,20) $CubeT=$Form.TextBox('',255,148,182,20) $NameT=$Form.TextBox('',255,173,182,20) $JackT=$Form.TextBox('',255,198,182,20) $SiteT.BackColor=$Form.RGB(255,245,225) $PhonT.BackColor=$Form.RGB(255,245,225) $CubeT.BackColor=$Form.RGB(255,245,225) $NameT.BackColor=$Form.RGB(255,245,225) $JackT.BackColor=$Form.RGB(255,245,225) ;---------------------------------------------------------------------------------------- $Frame2=$Form.Frame('Explain Problem*:',5,230,440,115) $ProbT=$Form.TextBox('',12,245,425,92) $ProbT.BackColor=$Form.RGB(255,245,225) $ProbT.MultiLine=1 $ProbT.WordWrap=1 ;---------------------------------------------------------------------------------------- $Frame3=$Form.Frame('Attachment:',5,348,440,42) $AttachT=$Form.TextBox('',12,362,425,20) $AttachT.BackColor=$Form.RGB(255,245,225) ;---------------------------------------------------------------------------------------- $Label7=$Form.Label('Requester:',12,398) $Label8=$Form.Label(@USERID,92,398) ;---------------------------------------------------------------------------------------- $AttachB=$Form.CommandButton('&Attach',219,396,70,20) $SubmitB=$Form.CommandButton('&Submit',293,396,70,20) $CancelB=$Form.CommandButton('&Close',367,396,70,20) $AttachB.OnClick='Attach_Click()' $SubmitB.OnClick='Submit_Click()' $SubmitB.Default=1 $CancelB.OnClick='Cancel_Click()' ;---------------------------------------------------------------------------------------- $Form.Show $SiteT.SetFocus ;---------------------------------------------------------------------------------------- WHILE $Form.Visible $RC=Execute($Form.DoEvents()) LOOP ;---------------------------------------------------------------------------------------- QUIT(1) ;---------------------------------------------------------------------------------------- FUNCTION Attach_Click() $AttachF=$Form.FileOpenDialog $AttachT.Text='$AttachF' ENDFUNCTION
;---------------------------------------------------------------------------------------- FUNCTION Cancel_Click() $Form.Hide ENDFUNCTION ;---------------------------------------------------------------------------------------- FUNCTION Submit_Click() DIM $FSite,$FPhon,$FCube,$FName,$FProb $FSite=$SiteT.Text $FPhon=$PhonT.Text $FCube=$CubeT.Text $FName=$NameT.Text $FProb=$ProbT.text IF(($FSite='')OR($FPhon='')OR($FCube='')OR($FName='')OR($FProb='')) $RC=$Form.MsgBox('All items marked with " * " are required.'+@CRLF+ 'Please enter all required information!', 'ITSoft - HelpDesk!') RETURN ENDIF Send_Mail() $SiteT.Clear $PhonT.Clear $CubeT.Clear $NameT.Clear $JackT.Clear $ProbT.Clear $AttachT.Clear ENDFUNCTION
FUNCTION Send_Mail() DIM $FSite,$FPhon,$FCube,$FName,$FJack,$FProb,$FAtta $FSite=$SiteT.Text $FPhon=$PhonT.Text $FCube=$CubeT.Text $FName=$NameT.Text $FJack=$JackT.Text $FProb=$ProbT.text $FAtta=$AttachT.Text ?$FAtta $P_REG='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices' $ID=0 $PRINTERS2='[ ' $PRINTERS=EnumValue($P_REG,$ID) DO $PRINTERS2=$PRINTERS2+$PRINTERS+' ][ ' $ID=$ID+1 IF(($ID=2)OR($ID=4)OR($ID=6)OR($ID=8)OR($ID=10)OR($ID=12)OR($ID=14)OR($ID=16)OR($ID=18)) $PRINTERS2=Left($PRINTERS2,Len($PRINTERS2)-2) IF(($T=EnumValue($P_REG,$ID))=0) $PRINTERS2=$PRINTERS2+@CRLF+' [ ';$RC ENDIF ELSE $PRINTERS2=$PRINTERS2 ENDIF $PRINTERS=EnumValue($P_REG,$ID) UNTIL @ERROR<>0 ;---------------------------------------------------------------------------------------- $DPRINT=ReadValue('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows','device') IF (len($DPRINT)=0) $DPRINTER='[ NONE ]' ELSE $PARRAY=Split('$DPRINT',',') $DPRINTER='[ '+$PARRAY[0]+' ]' ENDIF ;---------------------------------------------------------------------------------------- $x1=Ltrim(SubStr(@IPADDRESS0,01,3)) $x2=Ltrim(SubStr(@IPADDRESS0,05,3)) $x3=Ltrim(SubStr(@IPADDRESS0,09,3)) $x4=Ltrim(SubStr(@IPADDRESS0,13,3)) $IP=$x1+'.'+$x2+'.'+$x3+'.'+$x4 ;---------------------------------------------------------------------------------------- $RC=Open(1,$OUTPUT,5) $RC=WriteLine(1,'UserName = '+@USERID+@CRLF+ 'Full Name = '+$FName+@CRLF+ 'Site (Division) = '+$FSite+@CRLF+ 'Location (Cube-Jack) = '+$FCube+' - '+$FJack+@CRLF+ 'Phone Number (ext.) = '+$FPhon+@CRLF+ 'Computer Name = '+@WKSTA+@CRLF+ 'IP Address = '+$IP+@CRLF+ 'Operating System = '+@PRODUCTTYPE+@CRLF+ 'IE Version = '+IeVer()+@CRLF+ 'Processor Speed = '+@MHZ+@CRLF+ 'Installed Memory = '+MemorySize(0)+'_mb'+@CRLF+ 'Available Memory = '+MemorySize(1)+'_mb'+@CRLF+ 'Free Space on [C:\] = '+GetDiskSpace('C:\')+'_Kb | '+ (Val(GetDiskSpace('C:\'))/1024)+'_Mb'+@CRLF+ 'Default Printer = '+$DPRINTER+@CRLF+ 'Installed Printers = '+$PRINTERS2+@CRLF+ 'Date and Time = '+@DATE+' - '+@TIME+@CRLF+ '----------------------------------------------------------------'+@CRLF+ 'Explanation of Problem : '+@CRLF+@CRLF+$FProb) $RC=Close(1) ;---------------------------------------------------------------------------------------- IF(INGROUP('Mansfield')OR InGroup('FremontFE')OR InGroup('Southaven')OR InGroup('Lyons')) $EXSERVER = 'MANEX3NT' ELSE $EXSERVER = 'APPEX1NT' ENDIF $CMD=@CURDIR+'\blat.exe '+$OUTPUT+ ' -server '+$EXSERVER+ ' -t '+@USERID+'@@schoolspecialty.com'+ ' -f '+@USERID+'@@schoolspecialty.com'+ ' -s "ITSoft - HelpDesk! Request"'+ ' -attach "'+$FAtta+'"' SHELL $CMD IF(@ERROR=0) $RC=$Form.MsgBox('Your request has been submitted to the HelpDesk.', 'ITSoft - HelpDesk!',64) ELSE $RC=$Form.MsgBox('Your Request has not been submitted to the HelpDesk.'+@CRLF+ 'You will have to call SOS at extention 5333 to enter'+@CRLF+ ' a HelpStar Request! '+@CRLF+ '------------------ Error Message -------------------'+@CRLF+ '@SERROR', 'ITSoft - HelpDesk!',16) ENDIF ENDFUNCTION ;---------------------------------------------------------------------------------------- FUNCTION IeVer() ; Reference: Q164539 Global $IeLang Dim $IV,$IePrg,$Build,$ProgFilesDir $IeVer = 'Unknown' $IeLang = '' $IV = Left('' + ReadValue("HKLM\Software\Microsoft\Internet Explorer","Version"),8) If $IV Select Case Left($IV,4) = '4.71' $ieVer = '4.00' Case $IV = '4.72.210' $IeVer = '4.01' Case $IV = '4.72.311' $IeVer = '4.01 SP1' Case $IV = '4.72.361' $IeVer = '4.01 SP2' Case InStr('-5.00.251-5.00.291-5.00.292',$IV) > 1 $IeVer = '5.01' Case $IV = '5.00.310' $IeVer = '5.01 SP1' Case $IV = '5.00.331' $IeVer = '5.01 SP2' Case Left($IV,4) = '5.00' $IeVer = '5.00' Case InStr('-5.50.403-5.50.413',$IV) > 1 $IeVer = '5.50' Case $IV = '5.50.452' $IeVer = '5.50 SP1' Case $IV = '5.50.480' $IeVer = '5.50 SP2' Case InStr('-6.0.2462-6.0.2479-6.0.2600',$IV) > 1 $IeVer = '6.00' Case $IV = '6.0.2800' $IeVer = '6.00 SP1' Case $IV > '6.0.2800' $IeVer = '6.+' Case 1 Return EndSelect $IePrg = '' + ReadValue('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IE4\SETUP','Path') If $IePrg $RC = Execute('$$IePrg="$IePrg" + "\Iexplore.exe"') $IeLang = SubStr('' + GetFileVersion($IePrg,'Language'),5) EndIf Else $IV = '' + Left(ReadValue("HKLM\Software\Microsoft\Internet Explorer","IVer"),3) If $IV Select Case $IV = '100' $ieVer = '1.00' Case $IV = '101' $ieVer = '1.01 NT4' Case $IV = '102' $ieVer = '2.00' Case $IV = '103' $Build = '' + ReadValue("HKLM\Software\Microsoft\Internet Explorer","Build") Select Case InStr('-1155-1158',$Build) > 1 $ieVer = '3.00' Case $Build = '1215' $ieVer = '3.01' Case $Build = '1300' $ieVer = '3.02' Case 1 Return EndSelect Case 1 Return EndSelect $ProgFilesDir = ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','ProgramFilesDir') $IePrg = $ProgFilesDir + '\Internet Explorer\Iexplore.exe' If Exist($IePrg) $IeLang = SubStr('' + GetFileVersion($IePrg,'Language'),5) EndIf EndIf EndIf ENDFUNCTION
Well Damn! I figured this out before I hit the submit button. I changed this... $CMD=@CURDIR+'\blat.exe '+$OUTPUT+ to this... $CMD=@SCRIPTDIR+'\blat.exe '+$OUTPUT+
It seems that the FileOpenDialog was changing the @CURDIR from the Script's dir.
Maybe someone will find this usefull.(?)
Feel free to delete this any of you moderators.
Rocco
_________________________
I Love this board!!
--------------------
My DEV PC is running
KIX 4.22 WINXP Pro
|
|
Top
|
|
|
|
#92002 - 2003-05-12 05:53 PM
Re: Uh, Nevermind.....
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
The flag is for the FileOpenDialog itself. So more like (depending on version of KiXforms) this example from KiXomatic...
code:
$dlgOpen = $Form.FileOpenDialog("Open File",@SCRIPTDIR,,"KiX Files|*.kix|All Files|*.*",4)
...where the last property (e.g. "4") is the flag.
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 675 anonymous users online.
|
|
|