/* Adept v0.01 - 1.07 to Adept 1.08a5+ Menu Converter */

say 'Menu Converion Program for AdeptXBBS v1.08a v0.5.0'
say ''
say 'Run this program from in your Menus sub-directory'

Call CharOut, 'Enter in the Drive Letter Adept is installed on. [ie D:] : '
Pull Drive
If Pos(':',Drive) = 0 Then Drive = Drive || ':'

OldDirectory = Directory()

rc = Directory(Drive || '\Adept\Menus')

call RxFuncAdd 'SysLoadFuncs', 'rexxutil', 'SysLoadFuncs'
call 'SysLoadFuncs'

'@echo off'

RC = SysFileTree('*.menu', 'fline', 'FO')

do i = 1 to fline.0

   Pos = LASTPOS('\', fline.i)
   Len = LENGTH(fline.i)
   FileName = RIGHT(fline.i, (Len - Pos))

   NewName = FileName||'.New'
   OldName = FileName
   NewOld  = FileName||'.old'

   File = FileName

   Say File

   MenuLine = Strip(LineIn(File,1,1))

   do
      x = 0

      if(MenuLine == 'BEGINMENU') then do
         say File || ' Already Converted!'
      end
      else do
         if(MenuLine \= '') then
         RC = LineOut(NewName, 'BEGINMENU')

         if(MenuLine \= '') then do

            PARSE VALUE MenuLine WITH PromptText ',' Color ',' MenuFilename ',' MenuLocation ',' Flags

            if(PromptText \= '') then RC = LineOut(NewName, '    PROMPT           ' || PromptText)
            if(Color \= '') then Rc = LineOut(NewName, '    PROMPTCOLOR      ' || Color)
            if(MenuFileName \= '') then RC = LineOut(NewName, '    DISPLAYFILE      ' || MenuFileName)
            if(MenuLocation \= '') then RC =  LineOut(NewName, '    MENULOCATION     ' || MenuLocation)
            if(Flags \= '') then RC = LineOut(NewName, '    MENUFLAGS        ' || Flags)

            do while (Lines(File) == 1)
               MenuLine = Strip(LineIn(File))

               if(MenuLine == ';' | Left(MenuLine,1) == ';') then do
                  RC = LineOut(NewName, '  MENUCOMMENT            ' || MenuLine)
                  Iterate
               end

               if(MenuLine == '') then do
                  Iterate
               end

               PARSE VALUE MenuLine WITH Key ',' Command ',' OutputString ',' DataString ',' Color ',' MinAge ',' MaxAge ',' Sec1 ',' Sec2 ',' Flags1 ',' Flags2 ',' StartTime ',' EndTime ',' Gender ',' MinCredit ',' MaxCredit ',' MinTime ',' MaxTime ',' MinCall ',' MaxCall ',' MinPosts ',' MaxPosts ',' MinUpl ',' MaxUpl ',' MinDl ',' MaxDl ',' Group ',' PortFlags
               RC = LineOut(NewName, '    BEGINMENUITEM')
                  if(Key \= '') then          RC = LineOut(NewName, '        KEY              ' || Key)
                  if(Command \= '') then      RC = LineOut(NewName, '        MENUCOMMAND      ' || Command)
                  if(OutputString \= '') then RC = LineOut(NewName, '        DISPLAYSTRING    ' || OutputString)
                  if(Color \= '') then        RC = LineOut(NewName, '        DISPLAYCOLOR     ' || Color)
                  if(DataString \= '') then   RC = LineOut(NewName, '        DATAOPTION       ' || DataString)
                  if(MinAge \= '') then       RC = LineOut(NewName, '        MINAGE           ' || MinAge)
                  if(MaxAge \= '') then       RC = LineOut(NewName, '        MAXAGE           ' || MaxAge)
                  if(Sec1 \= '') then         RC = LineOut(NewName, '        MINSEC1          ' || Sec1)
                  if(Sec2 \= '') then         RC = LineOut(NewName, '        MINSEC2          ' || Sec2)
                  if(Flags1 \= '') then       RC = LineOut(NewName, '        FLAGS1           ' || Flags1)
                  if(FLags2 \= '') then       RC = LineOut(NewName, '        FLAGS2           ' || FLags2)
                  if(Gender \= '') then       RC = LineOut(NewName, '        GENDER           ' || Gender)
                  if(StartTime \= '') then    RC = LineOut(NewName, '        STARTTIME        ' || StartTime)
                  if(EndTime \= '') then      RC = LineOut(NewName, '        ENDTIME          ' || EndTime)
                  if(MinTime \= '') then      RC = LineOut(NewName, '        MINONLINETIME    ' || MinTime)
                  if(MaxTime \= '') then      RC = LineOut(NewName, '        MAXONLINETIME    ' || MaxTime)
                  if(MinCall \= '') then      RC = LineOut(NewName, '        MINCALLS         ' || MinCall)
                  if(MaxCall \= '') then      RC = LineOut(NewName, '        MAXCALLS         ' || MaxCall)
                  if(MinPosts \= '') then     RC = LineOut(NewName, '        MINPOSTS         ' || MinPosts)
                  if(MaxPosts \= '') then     RC = LineOut(NewName, '        MAXPOSTS         ' || MaxPosts)
                  if(MinUpl \= '') then       RC = LineOut(NewName, '        MINUPLOADS       ' || MinUpl)
                  if(MaxUpl \= '') then       RC = LineOut(NewName, '        MAXUPLOADS       ' || MaxUpl)
                  if(MinDl \= '') then        RC = LineOut(NewName, '        MINDOWNLOADS     ' || MinDl)
                  if(MaxDl \= '') then        RC = LineOut(NewName, '        MAXDOWNLOADS     ' || MaxDl)
                  if(Group \= '') then        RC = LineOut(NewName, '        GROUP            ' || Group)
                  if(PortFlags \= '') then    RC = LineOut(NewName, '        PORTFLAGS        ' || PortFlags)
               RC = LineOut(NewName, '    ENDMENUITEM')
            end
            RC = LineOut(NewName, 'ENDMENU')
            RC = LineOut(NewName)
            RC = LineOut(File)
            AdCmd = 'Ren ' || OldName || ' ' || NewOld
            AdCmd
            AdCmd = 'Ren ' || NewName || ' ' || OldName
            AdCmd
            say File || ' Converted'
         end
      end
   end
end
Call Directory(OldDirectory)
Say 'All Menus converted, Done..'
