home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / text / edit / FrexxEdA.lha / FrexxEd / fpl / GotoLabel.FPL < prev    next >
Text File  |  1995-07-19  |  1KB  |  54 lines

  1. export void GotoLabel()
  2. {
  3.   int line = ReadInfo("line");
  4.   int col = ReadInfo("byte_position");
  5.  
  6.   string labels[100];
  7.   int linenum[100];
  8.   string junk;
  9.   int numoflab=0;
  10.   int size=100;
  11.   const string validlabel= "^[ \t]*([a-zA-Z_0-9]*)[ \t]*:";
  12.   int moved;
  13.  
  14.   Visible(0);
  15.   GotoLine(1); /* from the start! */
  16.  
  17.   while(!Search(validlabel, "wf+")) {
  18.     junk = ReplaceMatch(validlabel, "\\1");
  19.     if(strlen(junk)) {
  20.       labels[ numoflab ] = junk;
  21.       linenum [ numoflab ] = ReadInfo("line");
  22.       numoflab++;
  23.       if(numoflab == size) {
  24.         /* Filled up the arrays, increase the sizes! */
  25.         size += 100;
  26.         resize labels[size];
  27.         resize linenum[size];
  28.       }
  29.     }
  30.   }
  31.   if(numoflab) {
  32.     string selection;
  33.     /* we've found some labels */
  34.     if(RequestWindow("Jump to label",
  35.                      "", "A", &labels, &selection, numoflab) &&
  36.        strlen(selection)) {
  37.       /* We have an OK! */
  38.       int a;
  39.       while(a < numoflab) {
  40.         if(!strcmp(selection, labels[a])) {
  41.           /* this is the label! */
  42.           GotoLine(linenum[a]); /* jump to the label! */
  43.           return;
  44.         }
  45.         a++;
  46.       }
  47.     }
  48.   }
  49.   else
  50.     ReturnStatus("No labels found!");
  51.   if(!moved)
  52.     GotoLine(line, col); // get back to start
  53. }
  54.