home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
wp
/
bmacs.zip
/
BMACS.DOC
next >
Wrap
Text File
|
1988-02-06
|
4KB
|
149 lines
;BRIEF macros by Gary Gruber
;
;Here are a couple of macros I use regularly to make screen drawing
;a breeze. PLUS and MINUS increment or decrement the numeric value of
;an @ SAY command's row and column coordinates. Place the cursor on the
;leftmost digit of the number to be converted. I leave the ASSIGN-TO-KEY
;statements up to you. These are great for moving windows around on screen
;without contantly typing in new numbers for a long series of @ SAY's.
;
;CENTER_LINE reads all the chars between two sets of double quotation marks
;(doesn't matter where on the line your cursor is) and then moves back to
;the column coordinate and inserts the appropriate coordinate to center
;the line on the screen display.
;
;Example: @ 2, say "This is the string to be centered."
;Don't enter the column coordinate. Call CENTER_LINE.
;
;LINE_LENGTH displays the length of the string between two sets of double
;quotation marks. I use this one when I need to erase a line with an
;@ x,y, say SPACE(?) statement.
;
#define COMMA ","
#define SPACE " "
(macro plus
(
(int int1 int2 num_digits new_num)
(= num_digits 2)
(string digit1 digit2 new_str)
(save_position)
(drop_anchor 1)
(= digit1 (read 1))
(next_char)
(= digit2 (read 1))
(if (|| (== digit2 SPACE) (== digit2 COMMA))
(= num_digits 1)
)
(= int1 (atoi digit1 1))
(if (== num_digits 1)
(
(prev_char)
(= new_num (++ int1))
)
)
(if (== num_digits 2)
(
(= int2 (atoi digit2 1))
(= new_num (+ (*= int1 10) int2))
(++ new_num)
)
)
(sprintf new_str "%d" new_num)
(delete_block)
(insert new_str)
(restore_position)
)
)
#define COMMA ","
#define SPACE " "
(macro minus
(
(int int1 int2 num_digits new_num)
(= num_digits 2)
(string digit1 digit2 new_str)
(save_position)
(drop_anchor 1)
(= digit1 (read 1))
(next_char)
(= digit2 (read 1))
(if (|| (== digit2 SPACE) (== digit2 COMMA))
(= num_digits 1)
)
(= int1 (atoi digit1 1))
(if (== num_digits 1)
(
(prev_char)
(= new_num (-- int1))
)
)
(if (== num_digits 2)
(
(= int2 (atoi digit2 1))
(= new_num (+ (*= int1 10) int2))
(-- new_num)
)
)
(sprintf new_str "%d" new_num)
(delete_block)
(insert new_str)
(restore_position)
(down)
)
)
(macro center_line
(
(int col_start col_end line_len center_pos diff real_len inter_pos)
(beginning_of_line)
(search_fwd "\"")
(next_char)
(inq_position NULL col_start)
(save_position)
(end_of_line)
(inq_position NULL col_end)
(restore_position)
(= diff (- col_end col_start))
(= real_len ( - diff 2))
(= inter_pos ( - 80 real_len))
(= center_pos ( / inter_pos 2))
(search_back ",")
(next_char)
(string output)
(sprintf output "%d" center_pos)
(insert output)
)
)
(macro line_length
(
(save_position)
(int col_start col_end line_len)
(beginning_of_line)
(search_fwd "\"")
(next_char)
(inq_position NULL col_start)
(search_fwd "\"")
(inq_position NULL col_end)
(restore_position)
(message "Line length = %d" (- col_end col_start))
)
)