boolstatus in SW VB

if i record a VB macro in SW2007 and view it afterwards, there is always lines who start with the word "boolstatus". what is this variable used for?

for example:

boolstatus = Part.Extension.SelectByID2("Point2@3DSketch1", "EXTSKETCHPOINT", 0.01523113840303, 0.01784208683388, 0.00822428053602, False, 0, Nothing, 0)

Reply to
Gil Alsberg
Loading thread data ...

This is why I keep harping on people to get at least a little VB literate before making macros.

In this case, "boolstatus" is a boolean variable. The variable is declared earlier in the macro by this line: Dim boolstatus As Boolean

The function "SelectByID2" returns a TRUE or FALSE and places it in the variable "boolstatus" to indicate whether the command was completed successfully.

If you're going to try to manipulate selections in a macro, you have some studying to do. You will need to learn how the Selection Manager object works and how to retrieve selections.

Reply to
That70sTick

What I didn't understand is which part of the code is using this TRUE/FALSE value in the code. I mean: O.K. - boolstatus has now a value of TRUE. but which part of the code after this decleration by SelectByID2 uses this value further? what is the purpose of giving a variable a value if no command uses it's value afterwards?

That's exactly what i'm trying to do: I've got some previuos knowladge of the Basic programming language (not VB) and i'm using the book "Automating SolidWorks 2006 using Macros" by Mike Spens to try and teach myself the principals of macro programming in SW. However, not every point is explained in that book or even in SW API help. so as last resort i turned to this NG.

Reply to
Gil Alsberg

So now we're a last resort! I see how it is! ;)

You don't need to use the "boolstatus" for anything. If you don't need it, you can ignore it. In fact, you could also run the SelectByID2 as a Sub instead of a Function (possible for all VB functions), and not use a return variable like boolstatus. (Sub = no return variable, Function = uses return variable)

The return variable ("Boolstatus", but could be ANY boolean variable you choose) is simply used a flag so that the program can check if the function completed its task successfully. For instance, you may execute the function and then have an IF-THEN statement to check boolstatus and perform actions accordingly.

Reply to
That70sTick

O.K. now i understand - thanks for the explanation! unfortunatly the transition from the '80 Basic language into VB is rather hard for me so these things are not obvious to me........

Cheers, Gil

Reply to
Gil Alsberg

Welcome to the club, Gil. :)

Gil Alsberg wrote:

Reply to
fcsuper

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.