home *** CD-ROM | disk | FTP | other *** search
- string xfplf_filename="FrexxEd:FPL/";
- export int ExecuteFPLFile(string title)
- {
- string newfile;
- newfile=PromptFile(xfplf_filename, title, "#?.FPL");
- if (strlen(newfile)) {
- xfplf_filename=newfile;
- ExecuteFile(newfile);
- } else
- ReturnStatus("Function cancel!");
- }
-
- export int Open(string file)
- {
- string name;
- int inputbuffer=GetEntryID();
- int id=inputbuffer;
- int ret;
-
- if (ReadInfo("changes") || ReadInfo("size"))
- id=New(); /* If the buffer isn't empty or is changed, open a new */
- if (id) {
- CurrentBuffer(id);
- if (id!=inputbuffer || strlen(file))
- ret=Load(file, "Open file:");
- else
- ret=Load("", "Open file:", ReadInfo("full_file_name", id));
- CurrentBuffer(inputbuffer);
- if (ret<0) {
- if (id!=inputbuffer)
- Kill(id);
- id=0;
- } else {
- if (id!=inputbuffer) {
- Activate(id);
- CurrentBuffer(id);
- }
- }
- }
- ReturnStatus(GetReturnMsg(ret));
- return(id);
- }
-
- export int SaveAs()
- {
- string name;
- int ret=1;
-
- name=PromptFile(ReadInfo("full_file_name"), "Save As", "", "s");
-
- if (strlen(name)) {
- if(Check(name))
- ret = Request("File already exists!\nDo you want to replace it?");
- if(ret) {
- Rename(name);
- if(0 > Save()) {
- ReturnStatus(GetReturnMsg(GetErrNo()));
- DisplayBeep();
- }
- }
- }
- }
-
-
- export int BlockLoad()
- {
- string filename;
-
- if (!strlen(filename))
- filename=PromptFile("", "Load Block!");
-
- if (strlen(filename)) {
- string file;
- int ret;
- file=LoadString(filename);
- ret=StringToBlock(file);
- if (ret!=0) {
- ReturnStatus(GetReturnMsg(ret));
- DisplayBeep();
- }
- }
- }
-
- export int BlockSave()
- {
- string filename;
-
- if (!strlen(filename))
- filename=PromptFile("", "Save Block!");
-
- if (strlen(filename)) {
- string file;
- int ret;
- file=GetBlock();
- ret=SaveString(filename, file);
- if (ret<0) {
- ReturnStatus(GetReturnMsg(ret));
- DisplayBeep();
- }
- }
- }
-
- export int SaveChanges() /* Save only a changed buffer */
- {
- if (ReadInfo("changes")) {
- if(0 > Save()) {
- ReturnStatus(GetReturnMsg(GetErrNo()));
- DisplayBeep();
- }
- } else
- ReturnStatus("No changes need to be saved!");
- }
-
- export int SaveAll() /* Save all buffers */
- {
- int currentid=GetEntryID();
- int firstid=GetBufferID();
- int id=firstid;
-
- do {
- if (ReadInfo("type")&1) {
- if(0 > Save()) {
- ReturnStatus(GetReturnMsg(GetErrNo()));
- DisplayBeep();
- }
- }
- id=NextBuffer(id);
- if (id == firstid)
- id=0;
- else
- CurrentBuffer(id);
- } while (id);
- CurrentBuffer(currentid);
- }
- export int SaveAllChanges() /* Save all buffers */
- {
- int activeentry=GetEntryID();
- int firstid=GetBufferID();
- int id=firstid;
-
- do {
- if (ReadInfo("changes") && (ReadInfo("type")&1)) {
- if(0 > Save()) {
- ReturnStatus(GetReturnMsg(GetErrNo()));
- DisplayBeep();
- }
- }
- id=NextBuffer(id);
- if (id == firstid)
- id=0;
- else
- CurrentBuffer(id);
- } while (id);
- CurrentBuffer(activeentry);
- }
-
- /* The Print functions will save the print file to t:PrintFile, make
- a script to print it and start a new process that execute the script. */
-
- export int Print()
- {
- if (0 <= Save("t:PrintFile", "")) {
- if (0 <= SaveString("t:PrintSkript", "type >prt: t:PrintFile \n"
- "Delete >NIL: t:PrintFile \n"))
- System("run >NIL: Execute t:PrintSkript");
- }
- else {
- ReturnStatus(GetReturnMsg(GetErrNo()));
- DisplayBeep();
- }
- }
- export int BlockPrint()
- {
- if (0 <= SaveString("t:PrintFile", GetBlock())) {
- if (0 <= SaveString("t:PrintSkript", "type >prt: t:PrintFile \n"
- "Delete >NIL: t:PrintFile \n"))
- System("run >NIL: Execute t:PrintSkript");
- }
- else {
- ReturnStatus(GetReturnMsg(GetErrNo()));
- DisplayBeep();
- }
- }
-
- export int RenameQuery()
- {
- string name=PromptFile(ReadInfo("full_file_name"));
- if (strlen(name)) {
- int ret=1;
- if(Check(name))
- ret = Request(joinstr("File ", name, " already exists!\nDo you really want this file name?"));
- if(ret)
- Rename(name);
- }
- }
-
- export int SaveQuery()
- {
- return(!Request(joinstr("File \"", ReadInfo("full_file_name"), "\"\nhas been changed after FrexxEd loaded it.\nSave it anyway?")));
- }
-
- Hook("FileChanged", "SaveQuery");
-
-