Macro Brief 01: FCW-06

Macros: Converting the DOS Divide macros for use in FastCAD 32


Contents

  1. Introduction
  2. The Divide Macros
  3. General Conversion Notes
  4. Installing these Macros
  5. The Macro Code
  6. Summary
Download the file divmac.exe. This will provide you with all needed files.

It is a self-extracting zip file that includes the macro file, this file in text form, and a couple of sample icons you can use to customize your icon bars. It should be extracted into your working FastCAD 32 directory (fcad32 on most systems).


Introduction

The following macros were originally created in 1990 for the DOS version of FastCAD. They've been converted here for use in FastCAD 32. The purpose of this macro brief is to provide: Note that the entire set of 123 original DOS macros can be downloaded directly from this web site.


The Divide Macros

The following text describes each macro function and its use. The actual code is presented both at the end of this document and in a separate file, divide.mac.

DV1 divides lines with small line segments into a typed-in number of sections. To use, select the line to divide. Then type in the tick length factor. The larger the number the smaller the length of the tick mark in relationship to the line being divided. Then type the number of divisions. The line will then be divided accordingly.

DV2 divides any entity with points. To use, select the line to divide, and type the number of divisions desired. Then type the number of the color of points you wish to use. The script will proceed to place points until all have been placed.

DV3 divides entities with points and then erases the original line. To use, select the line to divide, type the number of points to be drawn, and type the color number of the points. When the script is done placing points, the original entities will be erased.

DV4 divides entities with circles, a circle centerpoint at each division. To use, select the entity to divide, and type the number of divisions. The size of the circles drawn depends on the number of divisions, the more divisions the smaller the circles. This script will draw circles between each division and not on the endpoints with entities such as a Line or a Spline. In a continuous entity such as a Circle, Ellipse, or Smooth Polygon, the entity is evenly divided into segments. This script is a useful way of dividing entities into divisions that can be snapped to by using the center modifier on each circle, later the circles can be erased if necessary.

DV5 breaks a line into as many equal segments as typed in. To use, select the line to divide, and type the number of segments desired. The line will be broken into as many equal segments as you typed in.

DV6 breaks lines into equal segments and places a point at each break. To use, select the line to divide and type the number of segments. Then type the color number for the points to be placed. The line will be broken into the specified number of equal parts and a point will be placed at each break.


General Conversion Notes

Although the new FastCAD 32 and FastCAD DOS macro languages are fundamentally similar, there are several important diffferences between them. These differences require modification of any old DOS macros or scripts before they can be used in FastCAD 32.

The primary change involves syntax. FastCAD 32 macro lines do not end in a semicolon. As such, the trailing semi-colon from each line must be removed.

The SET command has been replaced by APND. Both commands are used for string concatenation. The SET command allowed multiple parameters, while the new APND command only accepts a single source variable or value. Thus, multiple APND statements are required where one SET statement previously sufficed. To create the string "<bear5,segdist" in the variable relcor5, note the different methods:

DOS Windows
SET relcor5 < bear5 , segdist GW relcor5 <
APND relcor5 bear5
APND relcor5 ,
APND relcor5 segdist

The GV command is now used instead of the CALC command to process arithmetic operations. When substituting the GV command, the equal sign (=) is deleted, and there should be no spaces between the operators and the operands.

SBANG and SDIST have been renamed GBRNG and GDIST, respectively.

Several IF statements are no longer available, such as IFLT (If Less Than) and IFLE (If Less Than or Equal). Use the IFP, IFZ, and IFN statements instead. Most testing statements can be suitably converted since the conditional statements can include arithmetic operators.

Another general change involves labels. The DOS version required the label be listed with a trailing colon. In the Windows version, labels must have a leading colon. For example:

Done: becomes :Done

The IFER command is now named IFERR. DOS IFER statements that were stacked at the end of a line (after a semicolon) must be moved to the next line.

Care should be taken that macro lines do not inadvertently end with a SPACE character. This can be tough to check because, on most text processors, spaces are impossible to detect except by running the cursor at the end of each line. Unfortunately, the presence of a SPACE character in an unintended position may render your macro inoperable. The only proper context for a trailing SPACE is at the end of a ^D statement. Such a SPACE separates the prompt from the typed-in user input.


Installing these Macros

There is no installation routine; the proper files simply need to copied to the proper folders and then loaded. After you download the files, the following files should be copied into your working FastCAD 32 folder (fcad32 on most systems):

divide.mac
divide1.bmp
divide5.bmp

One way to load the macros is to use the LOADMAC command [Macros > Load Macros], and selecting the file divide.mac. You can also copy the divide macro or macros you wish to use into the fcw32.mac file, so that it loads automatically with your other default macros.

Once these macros are loaded, they can be run by typing their name at the command prompt. Macros are named on the first line of the macro block. If you wish to rename the macro DV1 to D1, simply edit the first line of the macro block to read:

MACRO D1

You can also place custom macros into your menu. Doing so simply requires editing of the fcw32.mnu in a text editor. For instance, you might add the following line to the [Edit] menu:

Divide w/ticks:|DV1;

You also place all the macros into a nested menu (to save space). To do this, you can copy the following block of text into the [Edit] menu. Of course, you can modify the menu text to suit your preference.

------------:
Divide>:
 w/ticks:|DV1;
 w/points:|DV2;
 w/points, erase line:|DV3;
 w/circles:|DV4;
 into segments:|DV5;
 into segments & points:|DV6;

A custom icon can also be created for any macro can also be placed on the toolbar of your choice. Do this by creating an icon and editing the fcw32.imn file in a text editor. A couple of examples:

#204,divide.bmp:[Divide w/ticks]DV1;
or
#204,divide5.bmp:[Divide]DV5;

Of course, you can of course modify the graphics, placement, and functionality of these icons as you see fit. For more information on icon creation and placement, please see Technical Brief: FCW-05 Custom Icons in FastCAD 32.


The Macro Code

Note: This code is included in the ready-to-use macro file, divide.mac.

MACRO DV1
ECOFF
GP pickpt1 ON ^D Select entity to divide > 
IFERR Done
GV ticklen ^D Type N (tick length = entity length / N): 
IFERR Done
calctick
GN seg1 ^D Type number of segments: 
IFERR Done
IFN seg1-1 Done
GV spc 100/seg1
GV seg1 seg1-1
GV pct 0
:Loop
GV pct pct+spc
GP inspt % pct pickpt1
drawtick
GV seg1 seg1-1
IFP seg1 Loop
:Done
ECON
ENDM
MACRO CALCTICK
GBRNG ang0 % 0 pickpt1 % 100 pickpt1
GDIST len0 % 0 pickpt1 % 100 pickpt1
GV len0 len0/ticklen
GV ang0 ang0+90
ENDM
MACRO DRAWTICK
GV len1 len0/2
GW tostart <
APND tostart ang0
APND tostart ,
APND tostart len1
GW endpt ~
APND endpt 180
APND endpt ,
APND endpt len0
LINE REF inspt tostart endpt;
ENDM

MACRO DV2
ECOFF
GP #obj1 ON ^D Select entity to divide > 
IFERR Done
GN num1 ^D Type number of segments: 
IFERR Done
IFN num1-1 Done
GV per1 100/num1
GV per2 per1
GN col2 ^D Type number of color for points: 
IFERR Done
COLOR col2
:Loop
POINT % per2 #obj1;
GV per2 per2+per1
IFP per2-100 Done
GO Loop
:Done
ECON
ENDM

MACRO DV3
ECOFF
GP #obj ON ^D Select entity to divide > 
IFERR Over
GN num3 ^D Type number of line segments: 
IFERR Over
IFN num3-1 Over
GV per3A 100/num3
GV per3B per3A
GN col3 ^D  Type number of color for points: 
IFERR Over
COLOR col3
POINT % 0 #obj;
POINT % 100 #obj;
:Loop
POINT % per3B #obj;
GV per3B per3B+per3A
IFP per3B-100 Done
GO Loop
:Done
TRIM #obj % 100 #obj
SELBYP
ERASE
selbyd
REDRAW
:Over
ECON
ENDM

MACRO DV4
ECOFF
GP #obj4 ON ^D Select entity to divide > 
IFERR Done
GN num4 ^D Type number of segments: 
IFERR Done
IFN num4-1 Done
GV per4A 100/num4
GV per4B per4A
GDIST dia4A % 0 #obj4 % per4B #obj4
GV dia4B dia4A*.55
GP #obj0 % 0 #obj4
GP #obj100 % 100 #obj4
GDIST dist4 #obj0 #obj100
IFP dist4-dia4B Clp
GO Loop
:Clp
GN num4 num4-1
:Loop
CIRD dia4B % per4B #obj4;
GV per4B per4B+per4A
GN num4 num4-1
IFZ num4 Done
GO Loop
:Done
ECON
ENDM

MACRO DV5
ECOFF
GP #obj5 ON ^D Select entity to divide >
IFERR Done
GN num1 ^D Type number of segments to break line into:
IFERR Done
IFN num1-1 Done
GBRNG bear5 % 0 #obj5 % 100 #obj5
gv bear5 bear5*1
GDIST dist5 % 0 #obj5 % 100 #obj5
GV segdist dist5/num1
GP #0pt % 0 #obj5
GV segplus segdist
:Loop
GW $relcor5 <
APND $relcor5 bear5
APND $relcor5 ,
APND $relcor5 segdist
BREAK REF #0pt $relcor5 REF #0pt $relcor5 REF #0pt $relcor5
GV segdist segplus+segdist
GN num1 num1-1
IFZ num1 Done
GO Loop
:Done
ECON
ENDM

MACRO DV6
ECOFF
GP #obj6 ON ^D Select entity to divide > 
IFERR Done
GN num6A ^D Type number of segments: 
IFERR Done
IFN num6A-1 Done
GN col6 ^D Type color of points: 
IFERR Done
GN num6B num6A
GBRNG bear6 % 0 #obj6 % 100 #obj6
GV bear6 bear6*1
GDIST dist6 % 0 #obj6 % 100 #obj6
GV segdist dist6/num6A
GP #0pt % 0 #obj6
GV segplus segdist
:Loop1
GW relcor6 <
APND relcor6 bear6
APND relcor6 ,
APND relcor6 segdist
BREAK REF #0pt relcor6 REF #0pt relcor6 REF #0pt relcor6
GV segdist segplus+segdist
GN num6A num6A-1
IFZ num6A-1 Next
GO Loop1
:Next
COLOR col6
GV segdist segplus
:Loop2
GW relcor6 <
APND relcor6 bear6
APND relcor6 ,
APND relcor6 segdist
POINT REF #0pt relcor6;
GV segdist segplus+segdist
GN num6B num6B-1
IFZ num6B-1 Done
GO Loop2
:Done
ECON
ENDM


Summary

Macros can add a tremendous amount of functionality to your FastCAD 32 system. For the most part, your old DOS macros can be converted with a little work. Keep an eye out for more information on macro programming.

©1998 Evolution Computing, Inc.