Tuesday, November 11, 2008

Select an Element

QUEST SCL provides a function for selecting items (including elements) from the QUEST world, aptly named Select.   Basically, you tell the function what you want to pick (elements, cad_parts, etc...), the selection mode (mouse pick, pick from a list, or key in the name), and you pass in a string variable that will be set by the routine to the selected item's name (You also have to specify a text prompt, and whether or not you want the selected item to be highlighted).

I usually don't need to use all the available options in the Select function, so I've put together a routine I use often that I can drop into an SCL macro or call with an Extern reference, so here it is:

   routine select_an_element( prompt : String ) : Element
   Var
   elem_name : String
   picked_elem : Element
   Begin
      while( select( prompt , ELEMENT , PICK_MODE , TRUE , elem_name ) ) do
         picked_elem = get_element( elem_name )
      endwhile
      return picked_elem
   End

Like I said, this is just an easy to implement routine you can drop into your code without worrying too much about it, which is how I like to program...

No comments: