home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / TextEditors&Viewers / Texteditors / FFRED10.LHA / fpl / ExtraIO.FPL < prev    next >
Encoding:
Text File  |  1994-09-22  |  3.2 KB  |  158 lines

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