home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / FREDV19A.LHA / FrexxEd / fpl / SNMAMode.FPL < prev    next >
Encoding:
Text File  |  1995-07-21  |  4.8 KB  |  154 lines

  1. // $Id: SNMAMode.FPL 1.11 1995/07/21 10:40:09 jskov Exp $
  2. // $VER: SNMAMode.FPL 1.0 (15.06.95) © Jesper Skov
  3.  
  4. // The name of the SNMA ARexx port
  5. string SNMAddress="SNMA";
  6.  
  7. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» SNMA Preference Interface ««
  8. void export SNMAPrefs()
  9. {
  10.   PromptInfo(-1,"SNMA mode preferences",-1,-1,
  11.    "SNMA_auto_save",
  12.    "SNMA_assemble_dir",
  13.    );
  14. }
  15.  
  16.  
  17. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» checkSNMA() ««
  18. // Check that the SNMA port is present. Otherwise print error.
  19. //»»»»»»»»»»»»»
  20. int checkSNMA()
  21. {
  22.   if (!FindPort(SNMAddress,1)){
  23.     ReturnStatus("SNMA's AREXX port not found!");
  24.     return 0;
  25.   } else
  26.     return 1;
  27. }
  28.  
  29. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» getVar() ««
  30. // Get ARexx STEM variable contents.
  31. // This should be available directly from FrexxEd!
  32. //»»»»»»»»»»»»»»»»»»»»»»»»»»»
  33. string getVar(string varName)
  34. {
  35.   string t;
  36.   System(joinstr("rx >T:SNMAVarTmp \"address ",SNMAddress,"; INFO temp; say temp.",varName));
  37.   t=LoadString("T:SNMAVarTmp");
  38.   return substr(t,0,strlen(t)-1)
  39. }
  40.  
  41.  
  42. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» SNMAAssemble() ««
  43. export void SNMAAssemble()
  44. {
  45.   if (checkSNMA()){
  46.     string path;
  47.     Status(-1,"Assembling, please wait...");
  48.  
  49.     if (!strlen(path=ReadInfo("SNMA_assemble_dir"))) // Find assembly location
  50.       path=ReadInfo("file_path");                     // If none specified, use current
  51.     ARexxSend(SNMAddress, joinstr("CHDIR ",path));   // Tell SNMA
  52.  
  53.     Save(joinstr(path,ReadInfo("file_name")));       // Save source
  54.  
  55.     ARexxSend(SNMAddress, joinstr("ASM ",ReadInfo("file_name"))); // Start assembly
  56.  
  57.     if (ReadInfo("SNMA_auto_save"))
  58.       Save(ReadInfo("full_file_name"));
  59.  
  60.     if (!strcmp(getVar("STATUS"),"FAIL"))             // Wait for the result
  61.       ReturnStatus(joinstr("SNMA Failure: ",getVar("FAILSTR")));
  62.     else
  63.       ReturnStatus(joinstr("SNMA Result: ",getVar("STATUS"),". ",getVar("LINES")," lines, ",getVar("ERRORS")," errors."));
  64.   }
  65. }
  66.  
  67. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» SNMABuildGB() ««
  68. // Build includefile that will register needed includes in global table.
  69. // Problem: SNMA does not check for nested includes.
  70. // Solutions: 1) I get my slimy hand on the SNMA source.
  71. //            2) I make a FPL/C program which expands the nested includes to one file.
  72. //=====
  73. // Includes to be considered in main file must be inside a
  74. // ";;;;IncludeStart"
  75. // ";;;;IncludeEnd"
  76. // pair
  77. //»»»»»»»»»»»»»»»»»»»
  78. export void SNMABuildGB()
  79. {
  80.   if (checkSNMA()){
  81.     int y;
  82.     int incID=New();
  83.     GotoLine(1);
  84.     while(0<=Search(";;;;IncludeStart","=f+")){
  85.       y=ReadInfo("line")+1;
  86.       if (0<=Search(";;;;IncludeEnd","=f+"))
  87.         BlockCopyAppend(incID,1,y,1,ReadInfo("line"));
  88.       else
  89.         break;
  90.     };
  91.     incID=CurrentBuffer(incID);
  92.     Save("T:includeFile.gbt");
  93.     incID=CurrentBuffer(incID);
  94.     Kill(incID);
  95.     ARexxSend(SNMAddress, "CHDIR T:");
  96.     ARexxSend(SNMAddress, "ADDGB includeFile.gbt");
  97.     System("delete T:includeFile.gtb");
  98.     if (!strcmp(getVar("STATUS"),"FAIL"))
  99.       ReturnStatus(joinstr("SNMA Failure: ",getVar("FAILSTR")));
  100.     else
  101.       ReturnStatus(joinstr("SNMA Res: ",getVar("STATUS"),". ",getVar("LINES")," lines, ",getVar("ERRORS")," errors."));
  102.   }
  103. }
  104.  
  105. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» SNMAExtractAllErrors() ««
  106. export void SNMAExtractAllErrors()
  107. {
  108.   if (checkSNMA()){
  109.     int newID=GetBufferID("T:allErrors");
  110.     System("rx >T:allErrors frexxed:zmisc/SNMAAllErrors.rexx");
  111.     if (!newID) newID=New();
  112.     newID=CurrentBuffer(newID);
  113.     Clean("Load(\"T:allErrors\");");
  114.     SetInfo(-1,"tab_size",8);
  115.     Activate(newID);
  116.     CurrentBuffer(newID);
  117.   }
  118. }
  119.  
  120. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» SNMAExtractAllWarnings() ««
  121. export void SNMAExtractAllWarnings()
  122. {
  123.   if (checkSNMA()){
  124.     int newID=GetBufferID("T:allWarnings");
  125.     System("rx >T:allWarnings frexxed:zmisc/SNMAAllWarnings.rexx");
  126.     if (!newID) newID=New();
  127.     newID=CurrentBuffer(newID);
  128.     Clean("Load(\"T:allWarnings\");");
  129.     SetInfo(-1,"tab_size",8);
  130.     Activate(newID);
  131.     CurrentBuffer(newID);
  132.   }
  133. }
  134.  
  135. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Key bindings ««
  136. AssignKey("SNMAAssemble();", "control c control c", "snma_mode");
  137. AssignKey("SNMAExtractAllErrors();", "control c control e", "snma_mode");
  138. AssignKey("SNMAExtractAllWarnings();", "control c control E", "snma_mode");
  139.  
  140. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» SNMAMode preferences ««
  141.  
  142. ConstructInfo("SNMA_auto_save","","","GBWH","",0,1,1);
  143. ConstructInfo("SNMA_assemble_dir","","","GSWH","",0,0,"T:");
  144.  
  145. ConstructInfo("snma_mode","","","LBH","",0,1,0);
  146. ConstructInfo("snma_mode_ext","","","GSWH","",0,0,"*asm*s*i*");
  147. ConstructInfo("snma_mode_exe","","","GSWH","",0,0,"AsmModeInit();");
  148.  
  149. AddMode(1,"snma_mode", "snma_mode_ext", "snma_mode_exe"); // Add as major mode
  150.  
  151. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» SNMA menu ««
  152. MenuAdd("s", "SNMA...", "SNMAPrefs();", "", 6,6,-1); // Add to PackageSettings
  153. MenuBuild();
  154.