! ! Usage note: Change and to an actual TAB and SPACE. ! ! Routine: EVE_RENUMBER_LOCAL_LABELS ! ! Language: VAXTPU ! ! Author: Hunter Goatley (goathunter@WKUVX1.BITNET) ! Western Kentucky University ! Academic Computing, STH 266 ! Bowling Green, KY 42101 ! (502) 745-5251 ! ! Date: September 15, 1987 ! ! Functional description: ! ! Renumber MACRO local labels within a selected range. ! ! 11$: BRB 12$ 10$: BRB 30$ ! 23$: BLBC R0,11$ --> 20$: BLBC R0,10$ ! 12$: BEQL 23$ 30$: BEQL 20$ ! ! To use: ! ! 1. Load this file into an EVE buffer. ! 2. Replace and with a TAB and a SPACE ! 3. Press DO and type: ! TPU EXECUTE(CURRENT_BUFFER) ! 4. Key GOLD-K has now been defined as RENUMBER LOCAL LABELS. ! ! External procedures called: ! ! HG$SET_TEXT_MODE ! Procedure eve_renumber_local_labels Local curr_label !Numeric value of current label ,incr !Amount to increment CURR_LABEL ,pat1 !Match labels at beg. of line ,pat2 !Match other label occurrences ,new_label !The new ASCII label ,labelnum !The numeric value of old label ,this_label !The new label ,labcnt !Count of labels replaced ,orig_pos !Original position in buffer ,save_pos !Temporary pos. saved in work ,this_range !The selected range ,found !Range from first search ,found2 !Range from secon search ,whitespace !Blank and TAB ,whitenumbers ! ,this_white !This whitespace ,old_mode !Text entry mode for buffer ; on_error; endon_error; if eve$x_select_position = 0 then message ("Select a range before using NEW LOCAL LABELS"); return; endif; whitespace := ASCII(9) + ASCII(32); whitenumbers := whitespace + '0123456789'; curr_label := 10; incr := 10; labcnt := 0; pat1 := line_begin & span (whitenumbers) & "$:"; this_range := select_range; !Finish the select range eve$x_select_position := 0; !Turn off the select range old_mode := hg$set_text_mode (INSERT); !Set buffer to INSERT mode tempbuf := create_buffer ("labeltemp"); !Create a work buffer orig_pos := mark(none); !Save this position position (tempbuf); !Move to the work buffer split_line; !Start with a blank line move_text (this_range); !Move the selected range in position (Beginning_of (tempbuf)); !Go to beginning of work buffer loop exitif mark(none) = end_of (tempbuf); !Exit if at end of work buffer found := search (pat1, forward, exact); !Look for a local label exitif found = 0; !If not found, exit loop position (found); !Go to it this_label := substr (current_line, 1, !Extract the local label index (current_line, "$")); !... edit (this_label, trim_leading); !Trim off blanks and tabs this_white := substr (current_line, 1, !Get the blanks and tabs index (current_line, this_label)-1); !... message("Replacing label "+this_label); !Print message erase (found); !Erase the local label ! ! Replace and with a TAB and a SPACE!!! ! pat2 := ANY (",+-=<") & this_label & !Match any occurrence (line_end | ANY (",-+;>")); ! of this local label new_label := str(curr_label) + "~|$"; !Make the new label (w/ junk) copy_text (this_white+new_label+":"); !Copy the new one in save_pos := mark(none); !Remember where we are position (beginning_of (tempbuf)); !Go to the range beginning loop found2 := search (pat2, !Look for occurrences of this forward, exact); ! local label exitif found2 = 0; !If not found, exit loop position (found2); !Go to it move_horizontal (1); !Skip over blank, tab, or comma found2 := search ((ANCHOR & this_label), forward, exact); erase (found2); !Erase it copy_text (new_label); !Copy the new label in endloop; !Loop until not found position (save_pos); !Go back to where we were move_horizontal (-current_offset); !Move back to beginning of line move_vertical (+1); !Move down one curr_label := curr_label + incr; !Increment the local label # labcnt := labcnt + 1; !Bump number of labels replaced endloop; if labcnt <> 0 then !Were any labels changed? position (beginning_of (tempbuf)); !Go to the range beginning move_horizontal (-1); !Back up so we'll find the 1st loop !Replace all "~|$" with "$" found := search ("~|$", forward, exact); !Look for new label exitif found = 0; !Exit if not found position (found); !Go to it erase_character (2); !Erase the "~|" endloop; !Loop for all message (fao ("!ZL label!%S changed.", labcnt)); else message ("No labels changed."); endif; position (beginning_of (tempbuf)); !Go to beginning of work buffer erase_line; !Erase the blank line at top position (orig_pos); !Move back to original buffer move_text (tempbuf); !Move the new text back in delete (tempbuf); ! and delete the work buffer hg$set_text_mode (old_mode); !Reset text entry mode EndProcedure; !EVE_RENUMBER_LOCAL_LABELS ! ! Procedure: HG$SET_TEXT_MODE ! ! Author: Hunter Goatley ! ! Date: May 10, 1988 ! ! Functional description: ! ! This procedure will set the text entry mode of the current buffer ! to either INSERT or OVERSTRIKE. It returns the original setting ! for the buffer. ! ! Calling sequence: ! ! old_mode := hg$set_text_mode (INSERT); !Make sure buffer is in INSERT ! .... ! hg$set_text_mode (old_mode); !Restore to original setting ! Procedure hg$set_text_mode (state) Local temp !Keyword - the original text entry mode setting ; temp := get_info (current_buffer, "mode"); !Get the current setting set (state, current_buffer); !Set to the new state return (temp); !Return old mode EndProcedure; ! hg$set_text_mode define_key ("eve_renumber_local_labels", key_name("K",shift_key), "Renumber local labels");