home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / EDG-CT1.DMS / in.adf / CT.run / Macros / Fix_Broken_Project.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-10-09  |  3.6 KB  |  160 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. Main:
  12. call OpenStuff()
  13. call Docs()
  14. call Routine()
  15. call CloseStuff()
  16. exit
  17. return
  18.  
  19. GetFile:
  20.     parse Arg Title, Path
  21.     Address FLY_1 SetString Path
  22.     Address FLY_1 GetFileNameNT Title
  23. return result
  24.  
  25.  
  26. GetPath:
  27.     parse Arg Title, Path
  28.     Address FLY_1 SetString Path
  29.     Address FLY_1 GetPathNameNT Title
  30. return result
  31.  
  32. GetText:
  33.     parse Arg Title, Text
  34.     Address FLY_1 SetString Text
  35.     Address FLY_1 GetStringNT Title
  36. return result
  37.  
  38.  
  39. OpenStuff:
  40.     address command "run CT:FLY"
  41.     do while (POS('FLY_1',SHOW('Ports')) = 0)
  42.         address command "wait 1"
  43.         end
  44.     TOASTERLIB="ToasterARexx.port"
  45.     call remlib('ToasterARexx.port')
  46.     call remlib('PROJECT_REXX_PORT')
  47.     call addlib('PROJECT_REXX_PORT' , 0)
  48.     call addlib(TOASTERLIB,0)
  49. return
  50.  
  51. CloseStuff:
  52.     Address FLY_1 Quit
  53.     call remlib('ToasterARexx.port')
  54.     call remlib('PROJECT_REXX_PORT')
  55.     exit
  56. return
  57.  
  58. YesOrNo: procedure
  59.     parse Arg Title,Yes,No
  60.     Address FLY_1 OK_TEXT Yes
  61.     Address FLY_1 CANCEL_TEXT No
  62.     Address FLY_1 AskYesNoNT Title
  63.     if result = "OK" then YesNo = 1
  64.     else YesNo = 0
  65. return YesNo
  66.  
  67. Info: 
  68.     parse Arg Title,Yes
  69.     Address FLY_1 OK_TEXT Yes
  70.     Address FLY_1 FYINT Title
  71. return
  72.  
  73. FindDrive:
  74.     address command "C:Info >RAM:FLY-List"
  75.     call open TempFile,"RAM:FLY-List",R
  76.     do until eof(TempFile)
  77.         line = readln(TempFile)
  78.         parse var line Drive" "Rest
  79.         if Drive = "FA0:" then 
  80.             Volume = word(Rest,7)":"
  81.     end
  82.     call close TempFile
  83.     address command "Delete >NIL: RAM:FLY-List"
  84. return Volume
  85.  
  86. GetFileName: procedure  
  87.    ARG CompleteName
  88.    c = lastpos("/",CompleteName)
  89.    if c = 0 then c = lastpos(":",CompleteName)
  90.    return substr(CompleteName, c + 1)
  91.  
  92.  
  93. GetPathName: procedure  
  94.    ARG CompleteName
  95.    c = lastpos(":",CompleteName)
  96.    if c = 0 then c = lastpos(":",CompleteName)
  97.    return left(CompleteName,c)
  98.  
  99. Docs:
  100. Answer = YesOrNo(" Do You Need Instructions?"," YES "," NO ")
  101. if Answer = 0 then return 
  102. Text = "This Macro will fix a project where the Flyer can't\
  103. find certain croutons. If you have moved files around\
  104. and the project you had can not find them this will\
  105. check each crouton and when it can not find a matching\
  106. file, it will come up with a requester to select a new\
  107. file to replace it with."
  108. Answer = YesOrNo(Text," Continue "," Exit ")
  109. if Answer = 0 then call CloseStuff()
  110.  
  111. return
  112.  
  113.  
  114. Routine:
  115.     start_loc=croutonspot()
  116.     call croutonpick(LAST)
  117.     project_end=croutonspot()
  118.     call croutonpick(FIRST)
  119.     current_spot=0
  120.  
  121.     do while (current_spot<project_end+1)
  122.            call croutonpick(current_spot)
  123.            current_spot=current_spot+1
  124.            Location=(croutongettag(OriginalLocation))
  125.            if ~exists(Location) then call FixCrouton(croutonname())
  126.            end
  127.     call croutonpick(start_loc)
  128.     Address FLY_1 FYINT "Project Has Been Fixed!"
  129.  
  130. return
  131.  
  132.  
  133. FixCrouton:
  134. parse arg oldcrouton
  135.  
  136.     if lastpos('/',oldcrouton,length(oldcrouton)-1)~=0 then do
  137.        filenam2=right(oldcrouton,(length(oldcrouton)-lastpos('/',oldcrouton,length(oldcrouton)-1)))
  138.        path2=left(oldcrouton,(lastpos('/',oldcrouton,length(oldcrouton))-1))
  139.        end
  140.     else do
  141.        filenam2=right(oldcrouton,(length(oldcrouton)-lastpos(':',oldcrouton,length(oldcrouton)-1)))
  142.        path2=left(oldcrouton,(lastpos(':',oldcrouton,length(oldcrouton))))
  143.        end
  144.  
  145.     Title = "Select New Crouton For "filenam2"!   "
  146.     FileName = GetFile(Title,path2)
  147.  
  148.     call croutonpick(current_spot-1)
  149.     call CROUTONSETTAG('OriginalLocation',FileName)
  150.  
  151. return
  152.  
  153. syntax:
  154. error:
  155.     Address FLY_1 OK_TEXT " OK "
  156.     Title = "An Error Was Found With This Macro On Line #"SIGL"!"
  157.     Address FLY_1 FYINT Title
  158.     Address FLY_1 Quit
  159. exit
  160.