Poll
Question:
(dcl_form_show) with variable
Option 1: no opt
votes: 0
Option 2: no opt
votes: 0
Hi.
I've just start to learn ODCL.
ODCL seems great to me.
I have a question.
When using (dcl_form_show) can I use the form name with variable?
example :
...
(setq *myForm "ODCL_Form1")
(dcl_form_show *myForm )
...
Thanks.
Yes.
Did you know that ODCL has variable names for each of your forms and Controls ?
ie
MyProject_MyForm
MyProject_MyForm_Label1
(defun C:MyCommand (/ Result)
(command "_OPENDCL") ; Load OpenDCL Runtime
(if (dcl_Project_Load "MyProject") ; Load project data from MyProject.odcl
(progn
(setq Result (dcl_Form_Show MyProject_MyForm))
; Note that this code does not execute until *after* the dialog is closed!
(if (= Result 1) (DoSomething))
)
)
(princ)
)
(defun c:MyProject_MyForm_OnInitialize (/)
(dcl_Control_SetCaption MyProject_MyForm_Label1 "Hello World!")
)
(defun c:MyProject_MyForm_CloseButton_OnClicked (/)
(dcl_Form_Close MyProject_MyForm)
)
Yes. I've read that in the Help and tutorial.
So I want to make the Form name with (strcat) Fun.
Like this :
(setq *form_name "Form1")
(setq *myForm (strcat "ODCL" *form_name ))
(dcl_form_show *myForm )
Can this be possible?
Sure. There are several samples in my mind:
1. Depending on which form should be shown you put the form object into a variable. I do it so with controls doing similiar the same. In this sample you have to know the forms which may be shown.
Sample:
(cond
((= intCondition 1) (setq oForm MyProj_Form1))
((= intCondition 2) (setq oForm MyProj_Form2))
((= intCondition 3) (setq oForm MyProj_Form3))
((= intCondition 4) (setq oForm MyProj_Form4))
); cond
(if oForm (dcl_form_show oForm))
2. If you don't know the form exactly or you want to run a loop there are two different ways
a) with strings
(defun form_show (strForm)
(if (member strForm (dcl_project_getforms "MyProject"))
(dcl_form_show "MyProject" strForm)
); if
); form_show
(form_show "MyForm1")
b) with objects
(defun form_show (strForm / oForm)
(if (setq oForm (eval (read (strcat "MyProject_" strForm))))
(dcl_form_show oForm)
); if
); form_show
(form_show "MyForm1")
Hope that helps.
Fred
:D Thanks Fred!
That's just what I want.
I didn't place the (eval) at proper position.
It saves me from making of hundreds variables.