Coding conventions

Started by nwgeo, October 17, 2007, 09:29:20 AM

Previous topic - Next topic

nwgeo

As I look across the various properties that can be set for objects, I am curious if people are making use of the (VarName) property.  It seems to allow for abbreviated referernces to OpenDCL objects instead of using fully qualified names.

[from the "Examples" directory, project LISTBOX.ODCL]
(dcl_LISTBOX_CLEAR ListBox_form1_listbox)

You could use this?
(dcl_LISTBOX_CLEAR frmMain_lstRecords)

...provided of course that you filled in the "(varName)=frmMain_lstRecords" in the property box for that particular listbox control?

My main question is this.  Do you [all], as developers, use this feature, or is it just easier to use the fully qualified reference to keep everything straight.  I can see this being the preferred method, especially since you may be "running" various DCL forms and objects from the same LISP project file.


BazzaCAD

This was left in for backwards compatibility with old V3.0 ODC projects. I think the recommended way of working now is to leave this blank and have OpenDCL generate the names automatically for you so you don't have to manage them.
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

nwgeo

That makes sense.  All of the references are easily accessed with cut-n-paste from the property box. 

I am trying to set the enabled and visible properties of the controls on a form.  From the object browser I get this:


Method GetControls as List of Controls
Returns a list of all controls on the form.

AutoLISP Syntax:
(Setq rValue (dcl_Form_GetControls MLTAddr_frmAddr))



Can I just loop through this returned list like this?

(foreach i rValue
  (dcl_Control_SetVisible i T)     ;turn ON
  (dcl_Control_SetEnabled i T)   ;enable control
);end FOREACH


BazzaCAD

I haven't tried that one.
(dcl_Form_GetControls) is a newer function, so let us know if it works.
Here's an example of why it was created:
http://www.opendcl.com/forum/index.php?topic=56.0
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

nwgeo

I will check it out.  Two more properties come to mind that would make this programmatic manipulation more streamlined:

1) TypeOf - allow the coder to determine the type of control when processing the collection returned by "dcl_Form_GetControls"
2) Tag - a user defined property on ALL objects

A "tag" would allow someone to affect a change on a subset of controls.  For example, change the font on four of the six command buttons on a form when the Tag="Blocks" and TypeOf="Command"

Maybe this belongs in the "Wish List" category....