home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / tools / aurora21 / cfgupd.aml < prev    next >
Text File  |  1995-08-10  |  3KB  |  125 lines

  1. /* ------------------------------------------------------------------ */
  2. /* Macro:        CFGUPD.AML                                           */
  3. /* Written by:   nuText Systems                                       */
  4. /*                                                                    */
  5. /* Description:  This macro saves the current configuration to        */
  6. /*               CONFIG.AML and COLOR.AML and recompiles the editor.  */
  7. /* ------------------------------------------------------------------ */
  8.  
  9.   include bootpath "define.aml"
  10.  
  11.   // load CONFIG.AML
  12.   file = bootpath "CONFIG.AML"
  13.   if not loadbuf file then
  14.     msgbox "Can't Open " + file  "Error!"
  15.     return
  16.   end
  17.  
  18.   // do for each variable in CONFIG.AML
  19.   loop
  20.  
  21.     // find the config variable
  22.     length = find "^ *set" 'x'
  23.     if length then
  24.       right length
  25.       nlength = find "[a-zA-Z0-9_]#" 'xl'
  26.       if nlength then
  27.  
  28.         // get config variable name and current value
  29.         varname = gettext (getcol) nlength
  30.         value = lookup varname 'prf'
  31.  
  32.         right nlength
  33.         if find "[~ ]" 'xl' then
  34.           startcol = getcol
  35.           if (find "//" 'rlg') and (find "[~ ]" 'xr') then
  36.             endcol = getcol
  37.             col startcol
  38.  
  39.             // delete the old value
  40.             delchar endcol - startcol + 1
  41.  
  42.             // insert the new (current) value
  43.             if not (sizeof value) then
  44.               instext "''"
  45.             elseif posnot "0-9" value then
  46.               value = sub '\\' '\\\\' value
  47.               value = sub '"' '\\"' value
  48.               instext '"' + value + '"'
  49.             else
  50.               instext value
  51.             end
  52.           end
  53.         end
  54.       end
  55.     else
  56.       break
  57.     end
  58.   end
  59.  
  60.   // save the new CONFIG.AML
  61.   if not (savebuf file) then
  62.     msgbox "Error saving " + file "Error!"
  63.     destroybuf
  64.     return
  65.   end
  66.   destroybuf
  67.  
  68.  
  69.   // function return the color name for a color attribute
  70.   function attrname (attr)
  71.     case attr
  72.       when  0 "black"       when  8 "darkgray"
  73.       when  1 "blue"        when  9 "brightblue"
  74.       when  2 "green"       when 10 "brightgreen"
  75.       when  3 "cyan"        when 11 "brightcyan"
  76.       when  4 "red"         when 12 "brightred"
  77.       when  5 "magenta"     when 13 "pink"
  78.       when  6 "brown"       when 14 "yellow"
  79.       when  7 "gray"        when 15 "white"
  80.     end
  81.   end
  82.  
  83.   // function to return foreground on background string for attr
  84.   // (used to modify color.aml files)
  85.   function fattrname (attr)
  86.     (pad (attrname attr & 0fh) 13 'l') + "on " +
  87.        (pad (attrname (attr & 0f0h) shr 4) 13 'l')
  88.   end
  89.  
  90.  
  91.   // load COLOR.AML
  92.   file = bootpath "COLOR.AML"
  93.   if not loadbuf file then
  94.     msgbox "Can't Open " + file  "Error!"
  95.     return
  96.   end
  97.  
  98.   // do for each palette item in COLOR.AML
  99.   i = 1
  100.   while i <= 100 do
  101.     length = find "^ *color.*//" 'x'
  102.     if length then
  103.       col (getlinebeg)
  104.       delchar length - (getcol - 1)
  105.       instext "color " + (fattrname (getpalette i)) + "//"
  106.     else
  107.       break
  108.     end
  109.     i = i + 1
  110.   end
  111.  
  112.   // save the new COLOR.AML
  113.   if not (savebuf file) then
  114.     msgbox "Error saving " + file "Error!"
  115.     destroybuf
  116.     return
  117.   end
  118.   destroybuf
  119.  
  120.   // recompile the editor
  121.   if not regen then
  122.     msgbox "Configuration has been saved."
  123.   end
  124.  
  125.