News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Statement parameter question

Started by Dr PR, July 29, 2012, 03:44:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dr PR

Here is a general question for macros/BasiCAD. Bear with me, I am a newbie at programming DesignCAD macros.

When a statement can return several variables is it necessary to define a variable for each item it can return, even if you don't need to use them all.

For example, the GETATTR statement is defined this way:

GETATTR entity, type {,select, laynum, group, red, green, blue, solid}

so it can potentially return eight bits of information about "entity."

If I just want to know the type, layer and group can I use the statement this way:

GETATTR entity, type, laynum, group

or is it necessary to write it this way:

GETATTR entity, type, select, laynum, group, red, green, blue, solid

and just ignore the variables I don't need?

****

Are the variable names predefined, or are valued assigned to the variable according to their position in the list? For example, the list is defined in this order:

GETATTR entity, type, select, laynum, group, red, green, blue, solid

and if I use the variable name "laynum" in a function it will be the number of the layer the entity is on. But if I write the statement this way:

GETATTR entity, solid, blue, green, red, group, laynum, select, type

will the variable "laynum" actually contain the green color value?

And what if I write it this way:

GETATTR entity, frangthorp, viggle, mercum, norgrb, jklj, neldur, gregl, virp

will the variable "frangthorp" actually return the type value?


****

Is it a general rule for all statements?


Phil



DesignCAD user since 1987

Lar

With GETATTR and PUTATTR the 1st two are required, the rest are optional (this is signified by the use of { and } in the help). The order is important, not the names. So, if you only need #6 you have to go through the first five. Just make sure not to use a name already in use by BasicCAD (like 'length', 'layer', 'val', etc. If I want to use a regular english word I double the last letter (eg, mann, instead of man) in case DT&Co or whom ever decides to make that a basiccad code some time in the future.

Once you use a variable name in GET you should, of course, use the same thing in PUT (in the same relative location, of course).

It generally works this way for all statements (at the moment I can't think of an exception... well, maybe 'Query' and 'Change'. I never used them with anything other than the variables in the help so I can't say for sure). Just make sure you don't use the same variable for a different purpose ldown the road. A variable is only equal to the last value it was given.

Lar

Dempsey

You may want to download the macro17 help file (BasicCAD documentation) as that contains also example and tips on using statements, functions SYS() and SYS$().
Dempsey

DrollTroll

Also take some care not to name your variables using statement or function names. Look in the Keywords topic to see which a pretty good overview of what you can't use for variable names. For example, that's why I use "laynum" instead of "layer" for one of the arguments in Getattr/Putattr
25 years with DesignCAD

Dr PR

DesignCAD user since 1987

Garry K

I guess I have macro13 help file. Where can I download macro17 - I understand it is the latest macro help file.

Dr PR

Here are a bunch of V17 macro docs.

Phil
DesignCAD user since 1987

JJG