home *** CD-ROM | disk | FTP | other *** search
- $macro_file BASIC;
-
- {******************************************************************************}
- { MULTI-EDIT MACRO }
- { }
- {Name: BASTEMP }
- { }
- {Description: Creates compiled or interpreted basic language constructs based }
- { on a single character to the left of the current cursor position. }
- { }
- { (C) Copyright 1988 by American Cybernetics, Inc. }
- {******************************************************************************}
-
- $MACRO BASTEMP;
-
- DEF_INT(Temp_Col,Temp_Insert,Temp_Line_Num,Next_Line_Num,For);
-
- Temp_Insert := Insert_Mode;
- If (At_EOL = FALSE) Then
- Goto END_OF_MAC;
- End;
-
- Insert_Mode := True;
- Temp_Col := C_COL;
-
- Left;
- {check the character to the left of the cursor}
-
- If (XPos(Cur_Char,'Ii',1)) Then
- {If it is an 'I', then make an 'IF THEN' construct}
- Goto_Col(Temp_Col);
- {Create construct}
- Text('F THEN');
- Goto_Col(Temp_Col + 2);
- Goto END_OF_MAC;
- End;
-
- If (XPos(Cur_Char,'WwFf',1)) Then
- {If it is an 'W', then make an 'WHILE WEND' construct}
- {If it is an 'F', then make an 'FOR NEXT' construct}
- For := (XPos(Cur_Char,'Ff',1) > 0);
- Goto MAKE_FOR_WHILE;
- End;
-
- {If none of the above, then return cursor to the original position and exit}
- Goto_Col(Temp_Col);
- Goto END_OF_MAC;
-
-
- MAKE_FOR_WHILE:
- {See if line numbers are used}
- Goto_Col(1);
- If ((Val(Temp_Line_Num,Get_Word(' ')) > 0) or (C_Col = 1)) Then
- {If not, set the variable to zero so no line number with be created}
- Temp_Line_Num := 0;
- Else
- {if so, check to see if there is a line number below}
- Down;
- Goto_Col(1);
- If ((Val(Next_Line_Num,Get_Word(' ')) > 0) or (C_Col = 1)) Then
- Next_Line_Num := 0;
- End;
- Up;
- End;
- Goto_Col(Temp_Col);
- {Create first line of construct}
- If (For) Then
- Text('OR');
- Else
- Text('HILE');
- End;
- {Create a new line}
- Cr;
- If (Temp_Line_Num <> 0) Then
- {If line numbers are used, then..}
- Goto_Col(1);
- If (Next_Line_Num <> 0) Then
- {If inserting between two numbered lines, then increment next line number by 1
- to allow as much room as possible for the body of the construct}
- Text(Str(Temp_Line_Num + 1));
- Else
- {Otherwise, increment by the "standard" 10}
- Text(Str(Temp_Line_Num + 10));
- End;
- End;
- {Create the last line of the construct}
- Cr;
- If (Temp_Line_Num <> 0) Then
- Goto_Col(1);
- If (Next_Line_Num <> 0) Then
- {If inserting between two numbered lines, then number the last line one less
- than the next line to allow as much room as possible for the body of the
- construct}
- Text(Str(Next_Line_Num - 1));
- Else
- {Otherwise, increment by the "standard" 10}
- Text(Str(Temp_Line_Num + 20));
- End;
- End;
- Goto_Col(Temp_Col - 1);
- {Insert the proper ending statement}
- If (For) Then
- Text('NEXT');
- Else
- Text('WEND');
- End;
-
- {Place cursor in the proper place for the user to begin writing the condition
- clause}
- Up;
- Up;
- Eol;
- Right;
- Goto END_OF_MAC;
-
- END_OF_MAC:
- Insert_Mode := Temp_Insert;
-
- END_MACRO;
-
-
- {******************************************************************************}
- { MULTI-EDIT MACRO }
- { }
- {Name: BAS_IND }
- { }
- {Discription: Performs semi-smart indenting for BASIC source code. }
- { }
- { Looks for the beginning keywords: For If While Sub Do Def }
- { If it finds them it will INDENT }
- { }
- { Looks for the ending keywords: End Wend Next Then Loop }
- { If it finds them it will UNDENT }
- { }
- { (C) Copyright 1988 by American Cybernetics, Inc. }
- {******************************************************************************}
- $MACRO BAS_IND;
- DEF_STR(Temp_String1,Temp_String2,Temp_String3);
- DEF_INT(Temp_Line_Num,Temp_Col1,Temp_Col2,Next_Line_Num,using_lnums,l_num,key_word);
-
- key_word := 1; {initialize key word flag}
- using_lnums := 1; {initialize using line no flag}
-
- If (At_EOL = False) Then {If we are not at the end of a line, then}
- Cr; {do a carrige return and exit}
- Goto END_OF_MAC;
- End;
-
- goto_col(1); {go to col 1 and}
- First_Word; {get to first word}
- temp_col1 := C_Col; {save col first word is on}
-
- temp_string1 := get_word(' ');
-
- if (length(temp_string1) <> 0) {if the line isnt blank convert it to}
- Then {it to an integer to see if they are using}
- if (val(temp_line_num,temp_string1) = 0) {line numbers if they are you must get the}
- then using_lnums := 0; {next word after the line number }
- while ((xpos(cur_char,word_delimits,1) <> 0)
- and (c_col < 40)) do
- right;
- end;
- temp_col2 := c_col; {save col first word after line no is on}
- Temp_String2 := Get_Word(' '); {read all letters until you reach a space }
- end;
- end;
-
- if ((using_lnums = 0) and (length(temp_string2) <> 0)) {if using lnums and tstring2 isn't blank}
- Then temp_string2 := ' ' + remove_space(lower(temp_string2)) + ' '; end; {remove leading & trailing spaces}
- if ((length(temp_string1)) <> 0)
- then temp_string1 := ' ' + remove_space(lower(temp_string1)) + ' '; end; {if no lnums remove spaces from tstr1}
-
- If (length(temp_string1) = 0) {if str1 is blank just do a cr}
- Then
- Eol;
- cr;
- GOTO_COL(1);
- end;
-
- If ((length(temp_string2) = 0) and (using_lnums = 0)) {if using line nums & str2 is blank}
- Then {you just need to write the next line no}
- call write_next_lnum;
- end;
-
- If (using_lnums = 0)
- Then
- if (pos(temp_string2,' for if while sub do def ') <> 0) {if you find a begin. keyword and }
- then {your using line nos you must write}
- key_word := 0; {the next line no and indent }
- call write_next_lnum;
- goto_col(temp_col2);
- indent;
- end;
- else if (pos(temp_string1,' for if while sub do def ') <> 0) {if you find a keyword and not using}
- then {line nos just indent }
- key_word := 0;
- eol;
- cr;
- goto_col(temp_col1); {goto where you typed the keyword and go forward}
- indent; {one tab stop}
- end;
- end;
-
- if (using_lnums = 0)
- then
- if (pos(temp_string2,' next then wend end loop ') <> 0) {if you find an ending keyword then }
- then {and your using line nos you must write}
- key_word := 0; {the line number go back to the col you}
- call write_next_lnum; {were at last and undent 1 tab stop}
- goto_col(temp_col2);
- undent;
- if c_col = 1 {If you undent and you were only at the first}
- then {tab stop put cursor at the of the number}
- while ((xpos(cur_char,word_delimits,1) = 0)) do
- right;
- end;
- right;
- end;
- end;
- else
- if (pos(temp_string1,' next then wend end loop ') <> 0)
- then
- key_word := 0;
- eol;
- cr;
- goto_col(temp_col1);
- undent;
- end;
- end;
-
- if (key_word <> 0)
- Then
- if (using_lnums = 0) then
- if (length(temp_string2) <> 0)
- then call write_next_lnum; {No keywords - with line no's}
- goto_col(temp_col2);
- end;
- else if (length(temp_string1) <> 0) {No keywords - no line no's - just text}
- then
- eol;
- cr;
- goto_col(temp_col1);
- end;
- end;
- end;
-
- goto end_of_mac;
-
- write_next_lnum: {before writing the next line no go }
- goto_col(1); {down and check the next line to see if}
- Down; {another line Number below }
- Temp_String3 := Get_Word(' ');
- Up;
- eol;
- cr;
- goto_col(1);
- If ((Temp_String3 = '') or (Val(Next_Line_Num,Temp_String3) <> 0)) {if there is no line number below}
- Then Text(Str(Temp_Line_Num + 10)); {just increment the "standard" 10}
- Else Text(Str(Temp_Line_Num + ((Next_Line_Num - Temp_Line_Num) / 2)));{Otherwise make increment approx. halfway}
- end; {between the line number above and the below}
- right;
- ret;
-
- END_OF_MAC:
- redraw;
- END_MACRO;