The Splash archive of examples of OpenDCL working with dcl-Form-startTimer with an accountant.
Working only with dcl-Form-startTimer I just need to control the time that the form will appear on the screen.
(defun c:splash/Form1#OnTimer ()
(dcl-Control-SetCaption Splash/Form1/Label1 (strcat "Loading..." (itoa *Count*)))
(setq *Count* (1- *Count*))
(if (/= *Count* -1)
(dcl-Form-StartTimer Splash/Form1 1000)
(dcl-Form-Close Splash/Form1)
)
(princ)
)
I tested the example below by changing the value for dcl-Form-startTimer but not working.
Can anyone tell me where this my mistake?
(defun c:splash/Form1#OnTimer ()
(dcl-form-starttimer Splash/Form1 1000)
(dcl-form-close Splash/Form1)
)
Where are you calling dcl-Form-StartTimer to start the timer? Also, calling dcl-Form-StartTimer inside the OnTimer handler looks like a mistake.
Quote from: owenwengerd on November 19, 2014, 02:57:38 PM
Where are you calling dcl-Form-StartTimer to start the timer? Also, calling dcl-Form-StartTimer inside the OnTimer handler looks like a mistake.
Hello Owen,
What I did was remove the funçãoque works with counter SPLASH.lsp file and it stopped working.
I do not understand what the function of the counter along with dcl-Form-startTimer.
Follows the code I modified
;;;
;;; Splash Sample
;;;
;;; This sample demonstrates the timer event with a splash screen.
;;;
;; Main program
(defun c:Splash (/ cmdecho)
;; Ensure OpenDCL Runtime is (quietly) loaded
(setq cmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "_OPENDCL")
(setvar "CMDECHO" cmdecho)
;; Load the project
(dcl-Project-Load (*ODCL:Samples-FindFile "Splash.odcl"))
;; Show the main form
(dcl-Form-Show Splash/Form1)
;; This is a modeless form, so (dcl-Form-Show) returns immediately,
;; leaving the event handlers to manage the form.
;;; (setq *Count* 4)
(c:splash/Form1#OnTimer)
(princ)
)
;|«OpenDCL Event Handlers»|;
(defun c:splash/Form1#OnTimer ()
;;; (dcl-Control-SetCaption Splash/Form1/Label1 (strcat "Loading..." (itoa *Count*)))
;;; (setq *Count* (1- *Count*))
;;; (if (/= *Count* -1)
(dcl-Form-StartTimer Splash/Form1 4000)
(dcl-Form-Close Splash/Form1)
;;;)
(princ)
)
(princ)
;|«OpenDCL Samples Epilog»|;
;;;######################################################################
;;;######################################################################
;;; The following section of code is designed to locate OpenDCL Studio
;;; sample files in the samples folder by prefixing the filename with
;;; the path prefix that was saved in the registry by the installer.
;;; The global *ODCL:Prefix and function *ODCL:Samples-FindFile
;;; are used throughout the samples.
;;;
(or *ODCL:Samples-FindFile
(defun *ODCL:Samples-FindFile (file)
(setq *ODCL:Prefix
(cond
( *ODCL:Prefix
) ;_ already defined
( (vl-registry-read
"HKEY_CURRENT_USER\\SOFTWARE\\OpenDCL"
"SamplesFolder"
)
) ;_ 32-bit location
( (vl-registry-read
"HKEY_LOCAL_MACHINE\\SOFTWARE\\OpenDCL"
"SamplesFolder"
)
) ;_ 32-bit location
( (vl-registry-read
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\OpenDCL"
"SamplesFolder"
)
) ;_ 64-bit location
)
)
(cond
((findfile file)) ; check the support path first
(*ODCL:Prefix (findfile (strcat *ODCL:Prefix file)))
(file)
)
)
)
;; If AllSamples is active, run the main function immediately; otherwise
;; display a banner. The extra gymnastics allow the sample name to be
;; specified in only one place, thus making it easier to reuse this code.
( (lambda (demoname)
(if *ODCL:AllSamples
(progn
(princ (strcat "'" demoname "\n"))
(apply (read (strcat "C:" demoname)) nil)
)
(progn
(princ (strcat "\n" demoname " OpenDCL sample loaded"))
(princ (strcat " (Enter " (strcase demoname) " command to run)\n"))
)
)
)
"Splash"
)
(princ)
;;;######################################################################
;;;######################################################################
;|«Visual LISP© Format Options»
(80 4 50 2 nil "end of " 80 50 0 0 2 nil nil nil T)
;*** DO NOT add text below the comment! ***|;
In your modified code, the form is always closed immediately after opening because the main function calls (dcl-Form-Show), then immediately calls (c:splash/Form1#OnTimer) which calls (dcl-Form-Close). Just replace (c:splash/Form1#OnTimer) with (dcl-Form-StartTimer Splash/Form1 4000) to start the timer. Then in your c:splash/Form1#OnTimer, just close the form; do not start the timer again. I hope this helps.
Quote from: owenwengerd on November 20, 2014, 06:30:48 AM
In your modified code, the form is always closed immediately after opening because the main function calls (dcl-Form-Show), then immediately calls (c:splash/Form1#OnTimer) which calls (dcl-Form-Close). Just replace (c:splash/Form1#OnTimer) with (dcl-Form-StartTimer Splash/Form1 4000) to start the timer. Then in your c:splash/Form1#OnTimer, just close the form; do not start the timer again. I hope this helps.
Hello Owen,
I did further testing and found the following.
1- I found that the call to the Form-OnTimer function is automatic after dcl-Form-StartTimer finish.
2 -I do not need to call (.... #Form-OnTime). Is that right?
3 -Why Form-OnTimer function can not be declared as a local function?
1) Yes, that is the purpose of calling (dcl-Form-StartTimer).
2) Correct. I answered this in the previous reply.
3) If you declare it as a local function, it will no longer exist by the time it is needed.
Quote from: owenwengerd on November 21, 2014, 07:14:56 AM
3) If you declare it as a local function, it will no longer exist by the time it is needed.
Thanks Owen
About this item I asked why could aver many functions (c: splash /...# OnTimer ...) in the same project.
dcl-Form-StartTimer is great.
Quote from: velasquez on November 21, 2014, 08:22:52 AM
About this item I asked why could aver many functions (c: splash /...# OnTimer ...) in the same project.
Sorry, your question is not clear. There is only one OnTimer function per form because a timer must be associated with a window, and the OpenDCL event design makes it simple to handle OnTimer as an event. This dictates the design.
Quote from: owenwengerd on November 21, 2014, 09:05:06 AM
Quote from: velasquez on November 21, 2014, 08:22:52 AM
About this item I asked why could aver many functions (c: splash /...# OnTimer ...) in the same project.
Sorry, your question is not clear. There is only one OnTimer function per form because a timer must be associated with a window, and the OpenDCL event design makes it simple to handle OnTimer as an event. This dictates the design.
Thanks for your answers Owen.