Progressbars

Started by vasch the stampede, December 15, 2017, 05:02:20 AM

Previous topic - Next topic

vasch the stampede

Hi everyone.
I have a problem with progressbars.

Why I don't get a continuous feed of the bar but it go from 0 to 100 to the finished procedure?

(COMMAND "OPENDCL")
(DEFUN c:Hello ()
(SETQ Untitled_01 '("YWt6A64IAACRUWlTBuLL68URbT9uuMENbBlrYWz0+s7WXFtu7s4czuNGrnv6ul26wlpEDpJmMmw5"
     "TH9SZJZWlteGbQY0QiQ6e2Nbe3tbbLH4bnf2hxiToqDzbE47kMoJhY2ysLCQsAmgoiIX3KNsGS69"
     "XNQSDeY/Z5nuuGAGfqCKfAMC9aUu+9hSY7jOaUca7twt+MNKBScyHeLB2Yaw3PxcBUfAGaa1XxHD"
     "NGYb+jQVpNg6su6tEhvwZN0p1JPpz285N1uIjPLl2SMEO6CdSADgkUpDzMLFnjXId7dqN2ZxT8pR"
     "MK0NdnXWHeCX5CmWIcvKI7I3Cl0K52UIm4iEvkozwZ0bz0EJEoPhVADYhvecIRBAT+YllnPs64d4"
     "qTOAC7p8za07QLHgh/OGFB4VwdWG1JzplndbfI0wp9E7Bt76AybFKjiezGK6agNwzSvTGe/gKyLZ"
     "yfcFr4ZBqwJzu1iUkQnPmSWg07FGD+RtSkafetCOx7YKFJXiCXJYRvVXyf2M3fcJaorv1Oa59IWq"
     "d6lcL4M34rx+pTs44Z1D/v0CID7GrKxMkPD0zbunoXVpYqFqQN8ojS+rtQgZAV+InfCNvDkr22At"
     "QteG9hwGrwILw3DVi/qUyV+SObABKRmLSPzLMdcr+XkSi+tOFTnlYCv/cSu7oymCPo/DAVYWUCYf"
     "9RlrsXlViOg6lXW0ADePE0uhmR45JcKcgpPwAC+dQXuh6Ghx148hI0CMjjtS5VJxFfuHexCGfLXK"
     "sNPCsgX8rNAJ3s+QHvHSR9LHybxBKutSVYjCVgEpiFu7JANfK1tvK+8rNzY7GZtVZI3chxALiMwO"
     "LCuDSMlAtST7haupn1HUyoBfKwC9eNYM+c21IYWB1spehd0VAP0VLNBBIbBx+Q=="
    )
) ;_ fine di setq
(DCL_FORM_SHOW Untitled_01/Form1)
(PRINC)
) ;_ fine di defun

(DEFUN c:Untitled_01/Form1/TextButton1#OnClicked (/)
;;; (alert "DADAD")
;;; (execute 100000)
(DCL-CONTROL-SETVALUE Untitled_01/Form1/ProgressBar1 43)
(DCL-MESSAGEBOX (ITOA (DCL-CONTROL-GETVALUE Untitled_01/Form1/ProgressBar1)))
(SETQ maxVal 10000)
(SETQ counter 0)
(WHILE (<= counter maxVal)
  (DCL-CONTROL-SETVALUE Untitled_01/Form1/ProgressBar1 (* (/ counter maxVal) 100))
  (PRINC)
  (SETQ counter (1+ counter))
  (DCL-CONTROL-REDRAW Untitled_01/Form1)
;;;  (DCL-CONTROL-REDRAW Untitled_01/Form1/ProgressBar1)
) ;_ fine di while
) ;_ fine di DEFUN

Fred Tomke

Hi, I'd like to say: bad code :)

try this event method:

(DEFUN c:Untitled_01/Form1/TextButton1#OnClicked (/)
(DCL-CONTROL-SETMINVALUE Untitled_01/Form1/ProgressBar1 0)
(DCL-CONTROL-SETMAXVALUE Untitled_01/Form1/ProgressBar1 10000)
(DCL-CONTROL-SETVALUE Untitled_01/Form1/ProgressBar1 43)
(WHILE (<= (DCL-CONTROL-GETVALUE Untitled_01/Form1/ProgressBar1)
    (DCL-CONTROL-GETMAXVALUE Untitled_01/Form1/ProgressBar1))
  (DCL-CONTROL-SETVALUE Untitled_01/Form1/ProgressBar1 (1+ (DCL-CONTROL-GETVALUE Untitled_01/Form1/ProgressBar1)))
  (PRINC)
  (DCL-CONTROL-REDRAW Untitled_01/Form1)
)
)


Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

vasch the stampede

#2
The problem is here:
(DCL-CONTROL-SETVALUE Untitled_01/Form1/ProgressBar1 (* (/ counter maxVal) 100))

Becose counter and maxVal are integer and counter will be allways

Since "counter" and "maxVal" are integers and "counter" will always be less or equal to "maxVal" then the ratio will always be 0 until the last loop where it will become 1.

This will work:
(DCL-CONTROL-SETVALUE Untitled_01/Form1/ProgressBar1 (/ (* counter 100) maxVal))

Certainly this works better:
(DCL-CONTROL-SETMINVALUE Untitled_01/Form1/ProgressBar1 0)
(DCL-CONTROL-SETMAXVALUE Untitled_01/Form1/ProgressBar1 maxVal)
(SETQ counter 0)
(WHILE (<= counter maxVal)
(DCL-CONTROL-SETVALUE Untitled_01/Form1/ProgressBar1 counter)
(SETQ counter (1+counter))
(DCL-CONTROL-REDRAW Untitled_01/Form1/ProgressBar1)
)