mvDCompile

* Select and compile a program from the specified file.

* let the application keep the state for us.

* Inputs:

*       accountName is the account to examine

*       fileName    is the file to examine

*       itemName    is the item to compile

*       flash       is a flag (1=yes, other = no) indicating

*                   if the program should be flash compiled.

*       catalog     is a flag (1=yes, other=no) indicating

*                   if the program should be cataloged.

*       submit      indicates todo the compile

*       serverpool  select server pool to restart

*

* Outputs:

*       accountList is a list of accounts in the system

*       fileList is the list of files in the account

*       itemList is the list of items in the file

*       poolList is the list of configured server pools

*

* State control:

*

* If accountName is invalid, return a list of accounts.

* If accountName is valid and fileName is invalid, return a

*    list of files in the account.

* If accountName and fileName are valid, return a list of

*    items in the file.

*

*

include wbp w3Include

accountName = ""

itemName    = ""

fileName    = ""

flash       = ""

catalog     = ""

err         = w3_OK

accountList = ""

itemList    = ""

fileList    = ""

poolList    = ""

submit      = ""

                                    

accountProp = ""                    ;* properties for each list

fileProp    = ""

itemProp    = ""

poolProp    = ""

results     = ""                     ;* compilation results

status      = ""                     ;* compilation status

trigger     = ""                     ;* object on form causing call

event       = ""                     ;* event causing call

serverpool  = ""

call w3GetVal(accountName, "accountList.col1")

call w3GetVal(itemName, "itemList.col1")

call w3GetVal(fileName, "fileList.col1")

call w3GetVal(flash, "flash")

call w3GetVal(catalog, "catalog")

call w3GetVal(trigger, "w3TriggerObject")

call w3GetVal(event,   "w3TriggerEvent")

call w3GetVal(serverpool, "ServerPool.Name")

CRT "account: ":accountName

CRT "file: ":filename

CRT "item: ":itemName

CRT "flash: ":flash

CRT "catalog: ":catalog

CRT "Pool: ":serverpool

validAccount   = 0         ;* assume invalid

validFile      = 0

validItem      = 0

okToCompile    = 1         ;* validation flag

if trigger = "submit" and event = "evClick" then

   if accountName = "" or fileName = "" or itemName = "" then

      results = "Account, File, and Item must be selected."

      okToCompile = 0

   end else

      options    = "("

      verb       = ""

      if flash = 1 then options := "o"

      if catalog = 1 then

         verb  = "compile-catalog"

      end else

         verb  = "compile"

      end

          

      cmd    = ""

      cmd<1> = "to ":accountName

      cmd<2> = ""                  ;* required for security

      cmd<3> = verb:" ":fileName:" ":itemName:" "

      if len(options) > 1 then cmd := options

      open accountName:",":fileName:"," to f.source then

           read x from f.source, itemName then

               convert char(13) to "" in x

               convert char(12) to "" in x

               write x to f.source, itemName           

           end else

               results = "Cannot read ":itemName

               okToCompile = 0

           end

      end else

           results = "Cannot open ":accountName:" ":fileName

           okToCompile = 0

      end   ;* account and file valid

   end    ;* account and file specified

   if okToCompile then

      CRT cmd

      execute cmd capturing results returning status

      results = cmd : @am : status : @am : results

   end

 

  convert @am to char(13) in results

 

end   ;* compile requested

* always leave something selected

if accountName # "" and fileName # "" then

   id = ""

   execute 'sselect ':accountName:',':fileName:','

   loop

      readnext id else exit

   while 1 do

*     CRT "Item: ":id

      itemList<-1> = id

      if id = itemName then

         itemProp<-1> = p_UCV_Focus

      end else

         itemProp<-1> = 0

      end

   repeat

   convert @am to @vm in itemList

   convert @am to @vm in itemProp

end

      

if accountName # "" then

   id  = ""

   execute 'sselect ':accountName:',, with A1 = "D]"'

   loop

      readnext id else exit

   while 1 do

*     CRT "File: ":id

      fileList<-1> = id

      if id = fileName then

         fileProp<-1> = p_UCV_Focus

      end else

         fileProp<-1> = 0

      end

   repeat

   convert @am to @vm in fileList

   convert @am to @vm in fileProp

end

id = ""

execute 'sselect mds with a1 = "D]"'

loop

   readnext id else exit

while 1 do

   CRT "Account: ":id

   accountList<-1> = id

   if id = accountName then

      accountProp<-1> = p_UCV_Focus

   end else

      accountProp<-1> = 0

   end

repeat

convert @am to @vm in accountList          

convert @am to @vm in accountProp

id = ""

execute 'sselect w3Config'

loop

   readnext id else exit

while 1 do

*  CRT "Pool: ":id

   poolList<-1> = id

   if id = serverpool then

      poolProp<-1> = p_UCV_Focus

   end

repeat

convert @am to @vm in poolList          

convert @am to @vm in poolProp

*   set up data for output

columnValues     = ""

columnNames      = ""

columnProperties = ""

columnNames<1>   = "accountList.col1"

columnNames<2>   = "fileList.col1"

columnNames<3>   = "itemList.col1"              

columnNames<4>   = "results"

columnNames<5>   = "ServerPool.Name"

columnValues<1> = accountList

columnValues<2> = fileList

columnValues<3> = itemList  

columnValues<4> = results     

columnValues<5> = poolList

columnProperties<1> = accountProp

columnProperties<2> = fileProp

columnProperties<3> = itemProp

columnProperties<4> = ""

columnProperties<5> = poolProp

call w3mvDInit("","")

call w3mvDInsert(columnNames, columnValues, columnProperties)

call w3mvDInput(err, 0, "")

return