home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
vxcliser.zip
/
VXREXX.2
/
VREDISPG.VRM
< prev
next >
Wrap
Text File
|
1994-12-23
|
13KB
|
429 lines
/* Custom mainline for macro */
signal on SYNTAX name _VRESyntax
signal _VREMain
_VRESyntax:
parse source . . _VRESourceSpec
call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL":" ErrorText(rc), "Error!"
call VRFini
exit 32000
_VREMain:
/*:VRX Main
*/
Main:
/* Uncomment to debug
call VRRedirectSTDIO "on"
trace ?r
signal on novalue
*/
/* Process the arguments.
Get the parent window.
*/
parse source . calledAs .
parent = ""
argCount = arg()
argOff = 0
if( calledAs \= "COMMAND" ) then do
if argCount >= 1 then do
parent = arg( 1 )
argCount = argCount - 1
argOff = 1
end
end
InitArgs.0 = argCount
if( argCount > 0 ) then
do i = 1 to argCount
InitArgs.i = arg( i + argOff )
end
drop calledAs argCount argOff
/* Load the windows
*/
call VRInit
parse source . . spec
_VREPrimaryWindowPath = VRParseFileName( spec, "dpn" ) || ".VRW"
_VREPrimaryWindow = VRLoad( parent, _VREPrimaryWindowPath )
drop parent spec
if( _VREPrimaryWindow == "" ) then do
call VRMessage "", "Cannot load window:" VRError(), , "Error!"
_VREReturnValue = 32000
signal _VRELeaveMain
end
/* Process events
*/
call Init
signal on halt
do while( \VRGet( _VREPrimaryWindow, "Shutdown" ) )
_VREEvent = VREvent()
interpret _VREEvent
end
_VREHalt:
_VREReturnValue = Fini()
call VRDestroy _VREPrimaryWindow
_VRELeaveMain:
call VRFini
exit _VREReturnValue
VRLoadSecondary: procedure
name = arg( 1 )
window = VRLoad( VRWindow(), VRWindowPath(), name )
call VRMethod window, "CenterWindow"
call VRSet window, "Visible", 1
call VRMethod window, "Activate"
return window
/*:VRX CN_Operations_DoubleClick
*/
CN_Operations_DoubleClick:
call Process
return
/*:VRX CN_Operations_ExpandTree
*/
CN_Operations_ExpandTree:
record = VRInfo( "record" )
child = VRMethod( "CN_Operations", "GetRecordAttr", record, "FirstChild" )
if child \= "" & VRMethod( "CN_Operations", "GetRecordAttr", child, "Caption" ) = " " then do
call VRSet "CN_Operations", "Painting", 0
window = VRWindow()
call VRSet window, "Pointer", "Wait"
/* Expand! First get rid of the temporary child */
call VRMethod "CN_Operations", "RemoveRecord", child
/* Now add all the children of the record */
type = VRMethod( "CN_Operations", "GetFieldData", record, CNField.3 )
if type = "HEADING" then do
parent = VRMethod( "CN_Operations", "GetRecordAttr", record, "Parent" )
if parent = "" then do
parenttype = ""
end
else do
parenttype = VRMethod( "CN_Operations", "GetFieldData", parent, CNField.3 )
end
if parenttype = "OBJECT" then do
rectype = "OBJECTMACRO"
end
else do
rectype = "MACRO"
end
caption = VRMethod( "CN_Operations", "GetRecordAttr", record, "Caption" )
if caption \= "Objects" then do
/* Get the children from the Macro stem */
stub = VRMethod( "CN_Operations", "GetFieldData", record, CNField.1 )
call VRMethod "CN_Operations", "AddRecordList", record, "First", "Macro." || stub || "."
end
end
else if type = "OBJECT" then do
objHnd = VRMethod( "CN_Operations", "GetFieldData", record, CNField.1 )
if( objHnd = "" ) then
objClass = VRMethod( "CN_Operations", "GetRecordAttr", record, "Caption" )
else
objClass = VRGet( objHnd, "ClassName" )
fname = GetFileName( objClass )
if( fname = "" ) then do
call VRMessage window, "No MTO file defined for" objClass "objects.", "Error"
return
end
call ListMacros fname, record
call stream fname, "c", "Close"
if (translate(objClass) = "EDITWINDOW") then do
call VRMethod objHnd, "ListChildren", "objects."
newrec.0 = 0
do i = 1 to objects.0
newrec.0 = newrec.0 + 1
newrec.i = ";" || VRGet(objects.i, "Name") || ";;;;" ||,
CNField.1 || ";" || objects.i || ";" ||,
CNField.2 || ";'';" ||,
CNField.3 || ";" || "OBJECT"
end
if (newrec.0 > 0) then do
call VRSortStem "newrec."
call VRMethod "CN_Operations", "AddRecordList", record, , "newrec.", "reclist."
do i = 1 to reclist.0
temp = VRMethod( "CN_Operations", "AddRecord", reclist.i, , " " )
end
end
end
end
call VRSet window, "Pointer", "<Default>"
call VRSet "CN_Operations", "Painting", 1
end
return
/* Get the name of the file listing all the object specific macros
*/
GetFileName: procedure expose VRXPath
parse arg objClass
fullname = ""
if translate(objClass) = "EDITWINDOW" then do
objClass = "Window"
end
if length( objClass ) > 8 then do
objClass = left( objClass, 8 )
end
fname = VRDir( VRXPath || "SYSTEM\" || objClass || "*.MTO", "N" )
if fname \= "" then do
fullname = VRXPath || "SYSTEM\" || fname
end
return fullname
/*:VRX Fini
*/
Fini:
call VRSet VRWindow(), "Visible", 0
return RetStr
/*:VRX Halt
*/
Halt:
signal _VREHalt
return
/*:VRX Init
*/
/*
ret = VREDispG( parent, edit, path )
Display a list of objects and general code areas
for which code can be generated.
Args:
parent Window parent or ""
edit 1 if in VRXEDIT
path VX-REXX home dir.
Returns:
Cancel ""
Object "OBJECT";<handle>
Macro "MACRO";<macroname>;<parms>
*/
Init: procedure expose InitArgs. RetStr VRXEdit VRXPath CNField. Macro.
if( RXFuncQuery( 'VRELoadMTCNInfo' ) ) then
call RXFuncAdd 'VRELoadMTCNInfo', 'MT', 'VRELoadMTInfo'
Macro.0 = 0
RetStr = ""
VRXEdit = InitArgs.1
VRXPath = InitArgs.2
window = VRWindow()
call VRMethod window, "CenterWindow"
parent = VRGet( window, "Parent" )
call VRSet window, "Pointer", "Wait"
call VRSet window, "Visible", 1
call VRSet "CN_Operations", "Painting", 0
call CreateFields
call ListObjects
call ListOperations
call VRMethod "CN_Operations", "SortRecords"
call VRSet "CN_Operations", "Painting", 1
call VRSet "PB_Okay", "Enabled", 1
call VRSet "PB_Cancel", "Enabled", 1
call VRSet window, "Pointer", "<default>"
call VRMethod window, "Activate"
return
/* CreateFields
Create the fields for the container
*/
CreateFields: procedure expose CNField.
do i = 1 to 3
CNField.i = VRMethod( "CN_Operations", "AddField", "String" )
parse var CNField.i "?FH" stuff
numzeros = 8 - length( stuff )
CNField.i = "?FH" || copies( "0", numzeros ) || stuff
end
return
/* AddRec
Add a record to the container
val.1 = null, self, or macroname, depending on type of record (val.3)
val.2 = parms
val.3 = type of record
*/
AddRec: procedure expose CNField.
parse arg parent, caption, val.1, val.2, val.3
newrec = VRMethod( "CN_Operations", "AddRecord", parent, , caption )
call VRMethod "CN_Operations", "SetFieldData", newrec, CNField.1, val.1, CNField.2, val.2, CNField.3, val.3
if val.3 = "OBJECT" | val.3 = "HEADING" then do
/* create a dummy child for the heading, so that
* the expander box will appear
*/
temp = VRMethod( "CN_Operations", "AddRecord", newrec, , " " )
end
return newrec
/* ListClasses
List all the non-virtual classes currently loaded.
*/
ListClasses: procedure expose classes.
call VRMethod "Application", "ListClasses", "list."
j = 0
do i = 1 to list.0
parse var list.i "classname='" class "'" . "virtual=" virtual .
if virtual = 0 then do
j = j + 1
classes.j = class
end
end
classes.0 = j
return
/* ListObjects
Fill the container with the objects in the user window.
If we are not in the VRXEdit environment just list the
available classes.
*/
ListObjects: procedure expose VRXEdit CNField. classes.
parent = AddRec( "", "Objects", "", "HEADING" )
newrec.0 = 0
if VRXEdit = 1 then do
newrec.1 = ";Application;;;;" || CNField.1 || ";" ||,
VRGet( "Application", "Self" ) || ";" ||,
CNField.2 || ";'';" ||,
CNField.3 || ";" || "OBJECT"
newrec.2 = ";Screen;;;;" || CNField.1 || ";" ||,
VRGet( "Screen", "Self" ) || ";" ||,
CNField.2 || ";'';" ||,
CNField.3 || ";" || "OBJECT"
newrec.0 = 2
call VRMethod "CN_Operations", "AddRecordList", parent, , "newrec.", "reclist."
do i = 1 to reclist.0
temp = VRMethod( "CN_Operations", "AddRecord", reclist.i, , " " )
end
windownum = 1
newrec.0 = 0
uwindow = VREMMWHandle( windownum )
do while (uwindow \= "")
newrec.windownum = ";" || VRGet(uwindow, "Name") || ";;;;" ||,
CNField.1 || ";" || uwindow || ";" ||,
CNField.2 || ";'';" ||,
CNField.3 || ";" || "OBJECT"
newrec.0 = windownum
windownum = windownum + 1
uwindow = VREMMWHandle( windownum )
end
end
else do
call ListClasses
pos = newrec.0
do i = 1 to classes.0
pos = pos + 1
newrec.pos = ";" || classes.i || ";;;;" ||,
CNField.1 || ";;" ||,
CNField.2 || ";'';" ||,
CNField.3 || ";" || "OBJECT"
end
newrec.0 = pos
end
call VRMethod "CN_Operations", "AddRecordList", parent, , "newrec.", "reclist."
do i = 1 to reclist.0
temp = VRMethod( "CN_Operations", "AddRecord", reclist.i, , " " )
end
return
/* Fill the container with functions not associated with any object.
*/
ListOperations: procedure expose VRXPath CNField. Macro.
call ListMacros VRXPath, ""
return
/* List all the macros from a file in the container.
* NB Somewhat different from VREDispO equivalent.
*/
ListMacros: procedure expose CNField. Macro. Headers.
parse arg fname, grandparent
if grandparent \= "" then do
gptype = VRMethod( "CN_Operations", "GetFieldData", grandparent, CNField.3 )
end
else do
gptype = ""
end
if gptype = "OBJECT" then rectype = "OBJECTMACRO"
else rectype = "MACRO"
call VRELoadMTCNInfo fname, "Headers.", "Macro.", ,
CNField.1, CNField.2, CNField.3, rectype, Macro.0
call VRMethod "CN_Operations", "AddRecordList", grandparent, , "Headers.", "reclist."
do i = 1 to reclist.0
temp = VRMethod( "CN_Operations", "AddRecord", reclist.i, , " " )
end
return
/*:VRX PB_Cancel_Click
*/
PB_Cancel_Click:
call Quit
return
/*:VRX PB_Okay_Click
*/
PB_Okay_Click:
call Process
return
Process:
/* Set record.0 to 0 to prevent raising a
* novalue exception
*/
record.0 = 0
call VRMethod "CN_Operations", "GetRecordList", "Selected", "record."
if record.0 \= 1 then return
rec = record.1
do i = 1 to 3
field.i = VRMethod( "CN_Operations", "GetFieldData", record.1, CNField.i )
end
if field.3 = "OBJECTMACRO" then do
parent = VRMethod( "CN_Operations", "GetRecordAttr", record.1, "Parent" )
grandp = VRMethod( "CN_Operations", "GetRecordAttr", parent, "Parent" )
objName = VRMethod( "CN_Operations", "GetRecordAttr", grandp, "Caption" )
RetStr = "OBJECTMACRO" || ";" || objName || ";" || field.1 || ";" || field.2
call Quit
end
else if field.3 = "MACRO" then do
RetStr = "MACRO" || ";" || field.1 || ";" || field.2
call Quit
end
return
/*:VRX Quit
*/
Quit:
call VRSet VRWindow(), "Shutdown", 1
return
/*:VRX Window1_Close
*/
Window1_Close:
call Quit
return