Back | Next Lesson

Calling All Sigmacs

In lesson #005 (Need More Input!), we had a 2x4 stud program that called other sigmacs.  This weeks lesson will explore this subject in more detail.

001     //stud
002     level 1u
003     
004     width  = 1.5"
005     
006     
007     stud  = $inpc(#strn,'Draw Which Stud',1,'2x4','2x6','2x8')
008     if stud == '2x4'
009             height = 3.5"
010     elseif stud == '2x6'
011             height = 5.5"
012     elseif stud == '2x8'
013             height = 7.5"
014     endif
015     
016     plowleft  = $inp(#point,'Lower Left Corner of Stud')
017     pupright  = A(plowleft + (width,height,0))
018     pupleft   = A(plowleft + (0,height,0))
019     plowright = A(plowleft + (width,0,0))
020     
021     ::pen;?
022     ::box;=plowleft;=pupright;:
023     ::pen;=2
024     ::sal;=plowleft;=pupright;=plowright;=pupleft;:
025     exit

Lines #021-024 call other sigmacs.

Classification

Way back in lesson #002 (First Sigmac "Hello World"), we spoke about a Sigmac's
classification and level.  You may want to review lesson #002 before reading on.  To quickly summarize:

The 'double colons' forces ARRIS to execute the 'system' command??:

099     :sal

Whereas the 'single colon' will execute the 'user' command (if any), else it will fall back and execute the 'system' command by the same name.

099     ::sal

Easy enough!  But if you stop reading now, your sigmac will pass control to the sal command and terminate.  Never returning the control to your sigmac and execute the remaining code after sal command.  'Control' is the current focus of ARRIS.

The sigmac's 'level', as specified in the
level statement, has nothing to do with the 'control' being passed between sigmacs or mnemonics.

Control

Get Control!  You have to first figure out what
sal expects in way of prompts/input.  So first, manually execute sal in ARRIS and write down the prompts and user input expected.

Now change the line to read:

099     ::sal;?;?;?;?;:Both of these  WILL ensure the return of the control to your sigmac and finish executing everything that follows.

Note:  You could use ?u to force the input to come from the keyboard and NOT another sigmac or mnemonic command.  I wouldn't, it gives your sigmac an attitude and renders it relatively useless when called by another sigmac.

Customize

You may want to change things up a bit with a more pertinent prompt relative to your sigmac.

097     p1=$inp(#point, 'First Fence Point to Define Search Window' )
098     p2=$inp(#point, 'Second Fence Point to Define Search Window' )
099     ::cpa;=p1;=p2;?;?;:

Special Key Options

But the
cpa command has an optional F10 (function key) in the first prompt to define special fence options (all, complex, workplane, etc.).  We could try . . .

099     ::cpa;='F10';?;?;?;:

I think not - it couldn't be that easy.  Introducing the @ character for specifying 'point' input via function keys.  The left hand side of the @ specifies a point variable and the right hand side specifies the actual function key (1-10, but 10 is represented by 0) to be applied to said point variable.

Since we don't require an actual point variable in our
cpa example, we'll use "0" as a place holder for the point variable.  Since we want to specify the F10 key, we'll use @0.  Therefore . . .

099     ::cpa;=0@0;='all';?;?;:

Will execute the cpa command, implement the optional F10 list of specialize fences, select "all" from the list, and continue with the standard 'reference point' and 'new point location' prompts.

Another cool feature of
@, is that it can be used as a crude 'entity select'.  For example:

098     p1=$inp(#point, 'Select Object' )
099     :dosomething; =p1

by itself will not position the database pointer to any object in the drawing, because the typical F1 input will only return the point coordinates under the cursor - not the point coordinates of the desired object.  It will work if the user knows to use the F3 when selecting the object.  Why not make it easy for the users by specifying the F3 key within your sigmac.

098     p1=$inp(#point, 'Select Object' )@3
099     :dosomething; =p1

or

098     p1=$inp(#point, 'Select Object' )
099     :dosomething; =p1@3

By appending @3 at the end, the database pointer IS positioned at the desired object - ready for action by your sigmac.  Granted, there are better ways of positioning the database pointer.

Likewise:

099     p1=$inp(#point, 'Select Point' )@2      /* F2 to override XY forcing
099     p1=$inp(#point, 'Select Line' )@5
099     p1=$inp(#point, 'Select Text' )@6
099     p1=$inp(#point, 'Select Intersection' )@7
099     p1=$inp(#point, 'Select RI' )@8


That's all for now,
Steve


This lesson was brought to you by SCG consulting. All written materials related to these Sigmac lessons are copyrighted by SCG and intended for personal use only. Any commercial or non-commercial reproduction for public use is prohibited without written consent from SCG.

Back | Next Lesson