home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / DVD!FX17.LHA / FrexxEd / fpl / ExtraIO.FPL < prev    next >
Encoding:
Text File  |  1995-05-31  |  4.3 KB  |  204 lines

  1. string xfplf_filename="FrexxEd:FPL/";
  2. export int ExecuteFPLFile(string title)
  3. {
  4.   string newfile;
  5.   newfile=PromptFile(xfplf_filename, title, "#?.FPL");
  6.   if (strlen(newfile)) {
  7.     xfplf_filename=newfile;
  8.     ExecuteFile(newfile);
  9.   } else
  10.     ReturnStatus("Function cancel!");
  11. }
  12.  
  13. export int Open(string file)
  14. {
  15.   string name;
  16.   int inputbuffer=GetEntryID();
  17.   int id=inputbuffer;
  18.   int ret;
  19.  
  20.   if (ReadInfo("changes") || ReadInfo("size"))
  21.     id=New();    /* If the buffer isn't empty or is changed, open a new */
  22.   if (id) {
  23.     CurrentBuffer(id);
  24.     if (id!=inputbuffer || strlen(file))
  25.       ret=Load(file, "Open file:");
  26.     else
  27.       ret=Load("", "Open file:", ReadInfo("full_file_name", id));
  28.     CurrentBuffer(inputbuffer);
  29.     if (ret<0) {
  30.       if (id!=inputbuffer)
  31.         Kill(id);
  32.       id=0;
  33.     } else {
  34.       if (id!=inputbuffer) {
  35.         Activate(id);
  36.         CurrentBuffer(id);
  37.       }
  38.     }
  39.   }
  40.   ReturnStatus(GetReturnMsg(ret));
  41.   return(id);
  42. }
  43.  
  44. export int SaveAs()
  45. {
  46.   string name;
  47.   int ret=1;
  48.  
  49.   name=PromptFile(ReadInfo("full_file_name"), "Save As", "", "s");
  50.  
  51.   if (strlen(name)) {
  52.     if(Check(name))
  53.       ret = Request("File already exists!\nDo you want to replace it?");
  54.     if(ret) {
  55.       Rename(name);
  56.       if(0 > Save()) {
  57.         ReturnStatus(GetReturnMsg(GetErrNo()));
  58.         DisplayBeep();
  59.       }
  60.     }
  61.   }
  62. }
  63.  
  64.  
  65. export int BlockLoad()
  66. {
  67.   string filename;
  68.  
  69.   if (!strlen(filename))
  70.     filename=PromptFile("", "Load Block!");
  71.  
  72.   if (strlen(filename)) {
  73.     string file;
  74.     int ret;
  75.     file=LoadString(filename);
  76.     ret=StringToBlock(file);    
  77.     if (ret!=0) {
  78.       ReturnStatus(GetReturnMsg(ret));
  79.       DisplayBeep();
  80.     }
  81.   }
  82. }
  83.  
  84. export int BlockSave()
  85. {
  86.   string filename;
  87.  
  88.   if (!strlen(filename))
  89.     filename=PromptFile("", "Save Block!");
  90.  
  91.   if (strlen(filename)) {
  92.     string file;
  93.     int ret;
  94.     file=GetBlock();
  95.     ret=SaveString(filename, file);
  96.     if (ret<0) {
  97.       ReturnStatus(GetReturnMsg(ret));
  98.       DisplayBeep();
  99.     }
  100.   }
  101. }
  102.  
  103. export int SaveChanges()  /* Save only a changed buffer */
  104. {
  105.   if (ReadInfo("changes")) {
  106.     if(0 > Save()) {
  107.       ReturnStatus(GetReturnMsg(GetErrNo()));
  108.       DisplayBeep();
  109.     }
  110.   } else
  111.     ReturnStatus("No changes need to be saved!");
  112. }
  113.  
  114. export int SaveAll()  /* Save all buffers */
  115. {
  116.   int currentid=GetEntryID();
  117.   int firstid=GetBufferID();
  118.   int id=firstid;
  119.  
  120.   do {
  121.     if (ReadInfo("type")&1) {
  122.       if(0 > Save()) {
  123.         ReturnStatus(GetReturnMsg(GetErrNo()));
  124.         DisplayBeep();
  125.       }
  126.     }
  127.     id=NextBuffer(id);
  128.     if (id == firstid)
  129.       id=0;
  130.     else
  131.       CurrentBuffer(id);
  132.   } while (id);
  133.   CurrentBuffer(currentid);
  134. }
  135. export int SaveAllChanges()  /* Save all buffers */
  136. {
  137.   int activeentry=GetEntryID();
  138.   int firstid=GetBufferID();
  139.   int id=firstid;
  140.  
  141.   do {
  142.     if (ReadInfo("changes") && (ReadInfo("type")&1)) {
  143.       if(0 > Save()) {
  144.         ReturnStatus(GetReturnMsg(GetErrNo()));
  145.         DisplayBeep();
  146.       }
  147.     }
  148.     id=NextBuffer(id);
  149.     if (id == firstid)
  150.       id=0;
  151.     else
  152.       CurrentBuffer(id);
  153.   } while (id);
  154.   CurrentBuffer(activeentry);
  155. }
  156.  
  157. /* The Print functions will save the print file to t:PrintFile, make
  158.    a script to print it and start a new process that execute the script. */
  159.  
  160. export int Print()
  161. {
  162.   if (0 <= Save("t:PrintFile", "")) {
  163.     if (0 <= SaveString("t:PrintSkript", "type >prt: t:PrintFile \n"
  164.                                          "Delete >NIL: t:PrintFile \n"))
  165.       System("run >NIL: Execute t:PrintSkript");
  166.   }
  167.   else {
  168.     ReturnStatus(GetReturnMsg(GetErrNo()));
  169.     DisplayBeep();
  170.   }
  171. }
  172. export int BlockPrint()
  173. {
  174.   if (0 <= SaveString("t:PrintFile", GetBlock())) {
  175.     if (0 <= SaveString("t:PrintSkript", "type >prt: t:PrintFile \n"
  176.                                           "Delete >NIL: t:PrintFile \n"))
  177.       System("run >NIL: Execute t:PrintSkript");
  178.   }
  179.   else {
  180.     ReturnStatus(GetReturnMsg(GetErrNo()));
  181.     DisplayBeep();
  182.   }
  183. }
  184.  
  185. export int RenameQuery()
  186. {
  187.   string name=PromptFile(ReadInfo("full_file_name"));
  188.   if (strlen(name)) {
  189.     int ret=1;
  190.     if(Check(name))
  191.       ret = Request(joinstr("File ", name, " already exists!\nDo you really want this file name?"));
  192.     if(ret)
  193.       Rename(name);
  194.   }
  195. }
  196.  
  197. export int SaveQuery()
  198. {
  199.   return(!Request(joinstr("File \"", ReadInfo("full_file_name"), "\"\nhas been changed after FrexxEd loaded it.\nSave it anyway?")));
  200. }
  201.  
  202. Hook("FileChanged", "SaveQuery");
  203.  
  204.