source: branches/guitools-2.0/smbprint/smbprint.VRX@ 804

Last change on this file since 804 was 804, checked in by Herwig Bauernfeind, 12 years ago

GUI-Tools: SMBPrint.cmd

File size: 4.7 KB
Line 
1/*:VRX Main
2*/
3/* Main
4*/
5Main:
6/* Process the arguments.
7 Get the parent window.
8*/
9 parse source . calledAs .
10 parent = ""
11 argCount = arg()
12 argOff = 0
13 if( calledAs \= "COMMAND" )then do
14 if argCount >= 1 then do
15 parent = arg(1)
16 argCount = argCount - 1
17 argOff = 1
18 end
19 end; else do
20 call VROptions 'ImplicitNames'
21 call VROptions 'NoEchoQuit'
22 end
23 InitArgs.0 = argCount
24 if( argCount > 0 )then do i = 1 to argCount
25 InitArgs.i = arg( i + argOff )
26 end
27 drop calledAs argCount argOff
28
29/* Load the windows
30*/
31 call VRInit
32 parse source . . spec
33 _VREPrimaryWindowPath = ,
34 VRParseFileName( spec, "dpn" ) || ".VRW"
35 _VREPrimaryWindow = ,
36 VRLoad( parent, _VREPrimaryWindowPath )
37 drop parent spec
38 if( _VREPrimaryWindow == "" )then do
39 call VRMessage "", "Cannot load window:" VRError(), ,
40 "Error!"
41 _VREReturnValue = 32000
42 signal _VRELeaveMain
43 end
44
45/* Process events
46*/
47 call Init
48 signal on halt
49 do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
50 _VREEvent = VREvent()
51 interpret _VREEvent
52 end
53_VREHalt:
54 _VREReturnValue = Fini()
55 call VRDestroy _VREPrimaryWindow
56_VRELeaveMain:
57 call VRFini
58exit _VREReturnValue
59
60VRLoadSecondary:
61 __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
62 if __vrlsWait then do
63 call VRFlush
64 end
65 __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
66 if __vrlsHWnd = '' then signal __vrlsDone
67 if __vrlsWait \= 1 then signal __vrlsDone
68 call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
69 __vrlsTmp = __vrlsWindows.0
70 if( DataType(__vrlsTmp) \= 'NUM' ) then do
71 __vrlsTmp = 1
72 end
73 else do
74 __vrlsTmp = __vrlsTmp + 1
75 end
76 __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
77 __vrlsWindows.0 = __vrlsTmp
78 do while( VRIsValidObject( VRWindow() ) = 1 )
79 __vrlsEvent = VREvent()
80 interpret __vrlsEvent
81 end
82 __vrlsTmp = __vrlsWindows.0
83 __vrlsWindows.0 = __vrlsTmp - 1
84 call VRWindow __vrlsWindows.__vrlsTmp
85 __vrlsHWnd = ''
86__vrlsDone:
87return __vrlsHWnd
88
89/*:VRX _ShowMsg
90*/
91_ShowMsg:
92 Buttons.1 = "OK"
93 Buttons.0 = 1
94 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
95return/*:VRX Fini
96*/
97Fini:
98 window = VRWindow()
99 call VRSet window, "Visible", 0
100 drop window
101return 0
102
103/*:VRX Halt
104*/
105Halt:
106 signal _VREHalt
107return
108
109/*:VRX Init
110*/
111Init:
112 window = VRWindow()
113/* call VRMethod window, "CenterWindow" */
114 call VRSet window, "Visible", 1
115 call VRMethod window, "Activate"
116 drop window
117return
118
119/*:VRX Main_Close
120*/
121Main_Close:
122 call Quit
123return
124
125/*:VRX Main_Create
126*/
127Main_Create:
128 ok = VRRedirectStdIO("ON")
129 PrintParms = VRGet("Application","Commandline")
130 say "Printparms='"Printparms"'"
131 say length(PrintParms)
132 if PrintParms <> "" then do
133 parse var PrintParms '"'spoolfile'" "'smbprintername'" "'Jobname'" "'pages'" "'JobSize'"'
134 say 'Verzeichnis: "'directory()'"'
135 say 'Spoolfile: "'spoolfile'"'
136 say 'Smbprinter: "'smbprintername'"'
137
138 ok = VRMethod( "Application", "ListPrinters", "printer." )
139 FoundQueue = 0
140 if ok = 1 then do
141 do i = 1 to printer.0
142 say printer.i
143 parse value printer.i with PName';'PQueue';'Rest
144 say PName'<-->'PQueue
145 if translate(PQueue) = translate(smbprintername) then do
146 FoundQueue = 1
147 leave
148 end
149 end
150 end
151
152 if FoundQueue then do
153 ok = VRset("DT_Job","Caption", 'Print "'Jobname'" ('Pages', 'JobSize' bytes) to "'PName'"')
154 ok = VRPrintFile( smbprintername, directory'\'spoolfile, , JobName )
155 ok = SysSleep(3)
156 /* ok = VRRedirectStdIO("OFF") */
157 end
158 else do
159 Msg.Title = "Samba Print Command for OS/2"
160 Msg.Type = "E"
161 Msg.Text = 'Invalid (non existent) print queue specified in smb.conf: "'smbprintername'"'
162 call _ShowMsg
163 end
164 ok = SysFileDelete(Spoolfile)
165 end
166 else do
167 Msg.Title = "Samba Print Command for OS/2"
168 Msg.Type = "I"
169 Msg.Text = 'smbprint.exe "spoolfile" "printerqueue" "jobname" "pages" "jobsize"'
170 call _ShowMsg
171 end
172 call Quit
173return
174
175/*:VRX Quit
176*/
177Quit:
178 window = VRWindow()
179 call VRSet window, "Shutdown", 1
180 drop window
181return
182
Note: See TracBrowser for help on using the repository browser.