PerfectScript Journal
 

April 1997 Macro Q&A

Assigning Selected Text to a variable (WPWin 6.1/7, WPDOS 6.1)

Q. I have a macro needs to get text that is typed in the document and use it as a parameter elsewhere in the macro. How can I do this?

A. Use the ?SelectedText (WPWin) or ?BlockedText (DOS) system variables. First, have the macro select the text, then add the following commands:

(WPWIN) vText:=?SelectedText SelectMode(off!)           
(DOS) vText:=?BlockedText BlockOff()             

The text is now assigned to variable vText, and can be used as a parameter in another macro command.

Q. I am writing a macro to create pleadings. The macro types names in the left column, moves to the right column, and types information there also. There needs to be a line between the two columns, but the height of the columns may vary. How can I calculate how tall the line should be?

A. You can use the ?Line system variable to get both the top position of the column, and the bottom position. The following macro code assumes you are already in column 1, and ready to move to column 2:

vBottom:=?Line
HardPageBreak
vTop:=?Line
vLength:=vBottom-vTop+200w
VLineCreate()
GraphicsLineEdit(Line: 1)
GraphicsLineLength(vLength)
GraphicsLineHorizontalPosition(BetweenColumns!; 1)
GraphicsLineVerticalPosition( Set!; vTop)
GraphicsLineEnd(State: Save!)           

The macro gets the line measurement of the bottom of column 1 and stores that value in variable vBottom. The value is stored in WPUnits, or 1200ths of an inch. Then the macro moves to column 2 and gets the top line (vTop).

The next command finds the distance between the bottom and top, and adds a bit of space to that value. Depending on your line height, you may need to adjust the distance.

Next, the line is created between the columns, using the variables found with the ?Line system variable. The result is a custom line between your columns.

 

Copyright Notice: The information included in the PerfectScript Journal is protected by US Copyright. The author grants you the right to use the routines in your own macros as needed. You may not sell, distribute, or publish them in any form.
If you choose to use the information here, you do so entirely at your own risk. No representations are made regarding the fitness of this information for your   particular purpose, or for your ability or inability to use the information. You   are advised to make backups of all relevant files before implementing any suggestion  or technique.
© Copyright 1997 by J. Jeppson.