/* Startup sequence 
 * Author:  Scott Blackledge (1988)
 */

Array. = ''
Count = 0

Address command

Say "VD0: Loaded"
Say "Commands running from VD0:C"

/*********************************************/
/* Running the Power-up Memory Test routine. */
/*********************************************/

'RUN > NIL: PUMemTest'
'WAIT 3'

/********************************************************************/
/* Move the System directory over to VD0 if needed and set up path. */
/********************************************************************/

If ~ EXISTS('VD0:System') then do
   'Makedir VD0:System'
   'Copy DF0:System VD0:System all'
End

'Assign System: VD0:System'
'Path VD0:System Add'
Call Manipulate add,'Path VD0:System Add'
Say "System directory running from VD0:System"

/***********************************************************************/
/* Move the Utilities directory over to VD0 if needed and set up path. */
/***********************************************************************/

If 0 then do /* I deleted the Utilities directory, so skip this section */

   If ~ EXISTS('VD0:Utilities') then do
      'Makedir VD0:Utilities'
      'Copy DF0:Utilities VD0:Utilities all'
   End

   'Path VD0:Utilities Add'
   Call Manipulate add,'Path VD0:Utilities Add'
   Say "Utilities directory running from VD0:Utilities"

End

/*******************************************************************/
/* Move the Fonts directory over to VD0 if needed and set up path. */
/*******************************************************************/

If 0 then do /* I deleted the Fonts directory, so skip this section */

   If ~ EXISTS('VD0:Fonts') then do
      'Makedir VD0:Fonts'
      'Copy DF0:Fonts VD0:Fonts all'
   End

   'Assign Fonts: VD0:Fonts'
   Say "Fonts are running from VD0:Fonts"

End

/******************************************************************/
/* Move the Devs directory over to VD0 if needed and set up path. */
/******************************************************************/

If ~ EXISTS('VD0:Devs') then do
   'Makedir VD0:Devs'
   'Copy DF0:Devs VD0:Devs all'
End

'Assign Devs: VD0:Devs'
Say "Devices will be loaded from VD0:Devs"
Say
Say "Note: New Preferences will go to VD0:Devs!"
Say

/******************************************************************/
/* Move the Libs directory over to VD0 if needed and set up path. */
/******************************************************************/

If ~ EXISTS('VD0:Libs') then do
   'Makedir VD0:Libs'
   'Copy DF0:Libs VD0:Libs all'
End

'Assign Libs: VD0:Libs'
Say "Libraries will be loaded from VD0:Libs"

/***************************************************************/
/* Move the S directory over to VD0 if needed and set up path. */
/***************************************************************/

If ~ EXISTS('VD0:S') then do
   'Makedir VD0:S'
   'Copy DF0:S VD0:S all'
End

'Assign S: VD0:S'
Say "Scripts will be looked for in VD0:S"

/***************************************************************/
/* Move the L directory over to VD0 if needed and set up path. */
/***************************************************************/

If ~ EXISTS('VD0:L') then do
   'Makedir VD0:L'
   'Copy DF0:L VD0:L all'
End

'Assign L: VD0:L'
Say "Handlers will be loaded from VD0:L"

/****************************************************************/
/* Move the Modula-2 disk over to VD0 if needed and setup path. */
/****************************************************************/

If ~ EXISTS('VD0:M2') then do

   If ~ EXISTS('DF1:M2') then do
      Say
      Address
      'Pause Please place the Modula-2 disk in DF1: and press enter'
      Address
   End

   /* Allow the EXEC to continue without loading the M2 files */

   If EXISTS('DF1:M2') then do
      'Makedir VD0:M2'
      'Copy DF1:M2 to VD0:M2 all'
      'Assign M2: VD0:M2'
      Say "Module-2 files will be loaded from VD0:M2"
      End
   Else do
      Say "Modula-2 file loading has been bypassed"
      Say
   End

End


/*************************************************************/
/* Move the Arexx disk over to VD0 if needed and setup path. */
/*************************************************************/

If ~ EXISTS('VD0:Rexx') then do

   If ~ EXISTS('DF1:Rexx') then do
      Address
      'Pause Please place the ARexxExecs disk in DF1: and press enter'
      Address
   End

   'Makedir VD0:Rexx'
   'Copy DF1:Rexx to VD0:Rexx all'
End

'Assign Rexx: VD0:Rexx'
Say "ARexx files will be loaded from VD0:Rexx"

/*****************************************************************/
/* Move the ENV: directory over to VD0 if needed and setup path. */
/*****************************************************************/

If ~ EXISTS('VD0:Env') then do

   'Makedir VD0:Env'

   If EXISTS('DF0:S/Env') then
      'Copy DF0:S/Env to VD0:Env all'
   Else
      Say "Unable to copy environmental data to VD0:"

End

'Assign Env: VD0:Env'
Say "Environmental data will be loaded from VD0:Env"

/*********************************************************************/
/* Make it possible to run completely with workbench disk installed. */
/*********************************************************************/

'Assign SYS: VD0:'
Say "DF0: may now contain any diskette"

Say "Workbench disk.  Release 1.2 version 33.47"
Say
Say "Use Preferences tool to set date"

'Mount PIP:'

'Run VD0:System/FaccII'
'Run POPCLI 600'

'Makedir RAM:T'
'Assign T: RAM:T'

Address
'Stack 30000'
Address

Call Manipulate queue

Exit 0

Manipulate:  /* Perform queueing functions */

Parse arg Function,Item
Function = Upper(Function)

Select
   When Function = 'ADD' then do
      Count = Count + 1
      Array.Count = Item
      End
   When Function = 'QUEUE' then do

      Do Current = 1 to Count
         temp = Array.Current
         Queue temp
         End

      End
   Otherwise
      Say "Invalid MANIPULATE function requested" (Function)
   End

Return 0

