boolstatus in SW VB

Discussion in 'SolidWorks' started by Gil Alsberg, Jan 7, 2007.

  1. Gil Alsberg

    Gil Alsberg Guest

    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)
     
    Gil Alsberg, Jan 7, 2007
    #1
  2. Gil Alsberg

    That70sTick Guest

    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.
     
    That70sTick, Jan 8, 2007
    #2
  3. Gil Alsberg

    Gil Alsberg Guest

    The function "SelectByID2" returns a TRUE or FALSE and places it in the
    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.
     
    Gil Alsberg, Jan 8, 2007
    #3
  4. Gil Alsberg

    That70sTick Guest

    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.
     
    That70sTick, Jan 9, 2007
    #4
  5. Gil Alsberg

    Gil Alsberg Guest

    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
     
    Gil Alsberg, Jan 9, 2007
    #5
  6. Gil Alsberg

    fcsuper Guest

    Welcome to the club, Gil. :)


     
    fcsuper, Jan 10, 2007
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...