home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / EDG-CT1.DMS / in.adf / CT.run / Macros / Add_ADPro_To_Flyer.rexx next >
Encoding:
OS/2 REXX Batch file  |  1995-10-09  |  5.1 KB  |  196 lines

  1. /*
  2.                         Control Tower Arexx Script
  3.                            Written By J.L. White
  4.                          (C)1995 Merlin's Software
  5. */
  6.  
  7. signal on error
  8. signal on syntax
  9. Options Results
  10.  
  11. Quotes = '22'X
  12. SingleQ = '27'X
  13.  
  14. Main:
  15. call OpenStuff()
  16. call Docs()
  17. call Routine()
  18. call CloseStuff()
  19. exit
  20. return
  21.  
  22. GetFile:
  23.     parse Arg Title, Path
  24.     Address FLY_1 SetString Path
  25.     Address FLY_1 GetFileNameNT Title
  26. return result
  27.  
  28.  
  29. GetPath:
  30.     parse Arg Title, Path
  31.     Address FLY_1 SetString Path
  32.     Address FLY_1 GetPathNameNT Title
  33. return result
  34.  
  35. GetText:
  36.     parse Arg Title, Text
  37.     Address FLY_1 SetString Text
  38.     Address FLY_1 GetStringNT Title
  39. return result
  40.  
  41.  
  42. OpenStuff:
  43.     address command "run CT:FLY"
  44.     do while (POS('FLY_1',SHOW('Ports')) = 0)
  45.         address command "wait 1"
  46.         end
  47.     TOASTERLIB="ToasterARexx.port"
  48.     call remlib('ToasterARexx.port')
  49.     call remlib('PROJECT_REXX_PORT')
  50.     call addlib('PROJECT_REXX_PORT' , 0)
  51.     call addlib(TOASTERLIB,0)
  52. return
  53.  
  54. CloseStuff:
  55.     Address FLY_1 Quit
  56.     call remlib('ToasterARexx.port')
  57.     call remlib('PROJECT_REXX_PORT')
  58.     exit
  59. return
  60.  
  61. YesOrNo: procedure
  62.     parse Arg Title,Yes,No
  63.     Address FLY_1 OK_TEXT Yes
  64.     Address FLY_1 CANCEL_TEXT No
  65.     Address FLY_1 AskYesNoNT Title
  66.     if result = "OK" then YesNo = 1
  67.     else YesNo = 0
  68. return YesNo
  69.  
  70. Info: 
  71.     parse Arg Title,Yes
  72.     Address FLY_1 OK_TEXT Yes
  73.     Address FLY_1 FYINT Title
  74. return
  75.  
  76. FindDrive:
  77.     address command "C:Info >RAM:FLY-List"
  78.     call open TempFile,"RAM:FLY-List",R
  79.     do until eof(TempFile)
  80.         line = readln(TempFile)
  81.         parse var line Drive" "Rest
  82.         if Drive = "FA0:" then 
  83.             Volume = word(Rest,7)":"
  84.     end
  85.     call close TempFile
  86.     address command "Delete >NIL: RAM:FLY-List"
  87. return Volume
  88.  
  89. GetFileName: procedure  
  90.    ARG CompleteName
  91.    c = lastpos("/",CompleteName)
  92.    if c = 0 then c = lastpos(":",CompleteName)
  93.    return substr(CompleteName, c + 1)
  94.  
  95.  
  96. GetPathName: procedure  
  97.    ARG CompleteName
  98.    c = lastpos(":",CompleteName)
  99.    if c = 0 then c = lastpos(":",CompleteName)
  100.    return left(CompleteName,c)
  101.  
  102. Docs:
  103. Answer = YesOrNo(" Do You Need Instructions?"," YES "," NO ")
  104. if Answer = 0 then return 
  105. Text = "This Macro will automatically add\
  106. Art Department Professional to the\
  107. Flyer Program Menu. You will have\
  108. the option to do it just for now or\
  109. to come up each time that you boot\
  110. the Flyer Software."
  111. Address FLY_1 OK_TEXT " Continue! "
  112. Address FLY_1 FYINT Text
  113.  
  114. return
  115.  
  116.  
  117. Routine:
  118.     Type = YesOrNo("Add ADPRO Now Or Always?"," NOW ","ALWAYS!")
  119.     call CreateAdd()
  120.     if Type = 0 then do
  121.         call CreateAlways()
  122.         end
  123.  
  124. return
  125.  
  126.  
  127. CreateAdd:
  128.     Name = "ADPro"
  129.     InFile = "ADPRO:ADPRO"
  130.     TOASTERLIB="ToasterARexx.port"
  131.     call remlib('ToasterARexx.port')
  132.     call remlib('PROJECT_REXX_PORT')
  133.     call addlib('PROJECT_REXX_PORT' , 0)
  134.     call addlib(TOASTERLIB,0)
  135.     call Addprogram(Name,"run SYS:rexxc/rx CT:Scripts2/4/"Name,0)
  136.  
  137.     call open TempFile,"CT:Scripts2/4/"Name,W
  138.     call writeln TempFile,"/* */"
  139.     call writeln TempFile,"options results"
  140.     call writeln TempFile,"TOASTERLIB="Quotes"ToasterARexx.port"Quotes
  141.     call writeln TempFile,"call remlib("SingleQ"ToasterARexx.port"SingleQ")"
  142.     call writeln TempFile,"call remlib("SingleQ"PROJECT_REXX_PORT"SingleQ")"
  143.     call writeln TempFile,"call addlib("SingleQ"PROJECT_REXX_PORT"SingleQ" , 0)"
  144.     call writeln TempFile,"call addlib(TOASTERLIB,0)"
  145.     call writeln TempFile,"call Switcher(TOWB)"
  146.     call writeln TempFile,"call remlib("SingleQ"ToasterARexx.port"SingleQ")"
  147.     call writeln TempFile,"call remlib("SingleQ"PROJECT_REXX_PORT"SingleQ")"
  148.     call writeln TempFile,"if (POS("SingleQ"ADPro"SingleQ",SHOW("SingleQ"Ports"SingleQ")) = 0)"
  149.     call writeln TempFile,"then do"
  150.     call writeln TempFile,"     Address Command "Quotes"run >NIL: "InFile""Quotes
  151.     call writeln TempFile,"end"
  152.     call writeln TempFile,"else do"
  153.     call writeln TempFile,"     address "Quotes"ADPRO"Quotes
  154.     call writeln TempFile,"     ADPro_To_Front"
  155.     call writeln TempFile,"end"
  156.     call writeln TempFile,"exit"
  157.     call close TempFile
  158.  
  159. return
  160.  
  161. CreateAlways:
  162.     parse Arg Program
  163.     Name = GetFileName(InFile)
  164.     call open TempFile,"CT:Scripts2/4/"Name".Load",W
  165.     call writeln TempFile,"/* */"
  166.     call writeln TempFile,"options results"
  167.  
  168.     call writeln TempFile,"do while (POS("SingleQ"PROJECT_REXX_PORT"SingleQ",SHOW("SingleQ"Ports"SingleQ")) = 0)"
  169.     call writeln TempFile,"Address command "Quotes"C:Wait 3"Quotes
  170.     call writeln TempFile,"end"
  171.  
  172.     call writeln TempFile,"TOASTERLIB="Quotes"ToasterARexx.port"Quotes
  173.     call writeln TempFile,"call remlib("SingleQ"ToasterARexx.port"SingleQ")"
  174.     call writeln TempFile,"call remlib("SingleQ"PROJECT_REXX_PORT"SingleQ")"
  175.     call writeln TempFile,"call addlib("SingleQ"PROJECT_REXX_PORT"SingleQ" , 0)"
  176.     call writeln TempFile,"call addlib(TOASTERLIB,0)"
  177.     call writeln TempFile,"call AddProgram("Quotes""Name""Quotes","Quotes"run SYS:rexxc/rx CT:Scripts2/4/"Name""Quotes",0)"
  178.     call writeln TempFile,"call remlib("SingleQ"ToasterARexx.port"SingleQ")"
  179.     call writeln TempFile,"call remlib("SingleQ"PROJECT_REXX_PORT"SingleQ")"
  180.     call writeln TempFile,"exit"
  181.     call close TempFile
  182.  
  183.     call open TempFile,"Toaster:Programs/StartToaster",A
  184.     call writeln TempFile,"rx >NIL: CT:Scripts2/4/"Name".Load"
  185.     call close TempFile
  186.  
  187. return
  188.  
  189. syntax:
  190. error:
  191.     Address FLY_1 OK_TEXT " OK "
  192.     Title = "An Error Was Found With This Macro On Line #"SIGL"!"
  193.     Address FLY_1 FYINT Title
  194.     Address FLY_1 Quit
  195. exit
  196.