Skip to content

Commit

Permalink
Added macro GOTO that jumps to a paragraph or section in a COBOL file…
Browse files Browse the repository at this point in the history
… (the name is determined from the word the cursor is currently on).
  • Loading branch information
Michael Knigge committed Oct 20, 2022
1 parent 984f7f2 commit 9230803
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions macros/goto.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
void goto(void)
{
int Start;
int End;
int Col;
int Len;
char *Word;
char *Text;
char *Suffix;

Text = SpfService("query", "line_data");
Col = SpfService("query", "col_number");
Len = SpfService("query", "line_length");
Suffix = "' ALL";

if(Text && Col >= 1 && Col <= Len)
{
while(Col > 1 && StrGetSubstr(Text, Col, 1) != " ")
Col--;

if(StrGetSubstr(Text, Col, 1) == " ")
Col++;

Start = Col;
End = StrFindSubstr(Text, " ", Start);

if(End <= Start)
{
if(Start > 1)
Start--;

End = Len;
}

Len = End - Start + 1;
Word = StrGetSubstr(Text, Start, Len);

StrStripLeading(Word, " ");
StrStripTrailing(Word, " ");

if(Start == 7)
StrStripTrailing(Word, ".");

if(StrFindSubstr(Text, "PERFORM ", 1) > 0)
Suffix = "' 8 ALL";

if(StrFindSubstr(Text, "GOTO ", 1) > 0)
Suffix = "' 8 ALL";

if(StrFindSubstr(Text, "PROCEDURE ", 1) > 0)
Suffix = "' 8 ALL";

SpfService("cmd", StrCompose("FIND '", Word, Suffix));
}
}

0 comments on commit 9230803

Please sign in to comment.