sharpooth Posted November 5, 2010 Author Posted November 5, 2010 Correct, then populate the list with the strings - but, really, the list_box is meant for user selection, not message display... Thank you Lee Mac! You are right - list_box is for selections, but for now this is the situations. Thanks of all guys! Quote
Lt Dan's legs Posted November 5, 2010 Posted November 5, 2010 (edited) untested (defun c:test (/ lst dcl filename f) (setq lst '("this is a test!" "this is only a test" "line 3" "line4" "line 5" "6" "7" "8" "9" "10")) (if (eq (findfile (setq filename (strcat (getvar 'roamablerootprefix) "Support\\test.dcl"))) nil) (progn (setq f (open filename "w")) (foreach str '("main" ": dialog {" " label = \"test\";" " : list_box {" " alignment = centered;" " key = \"list\";" " width = 35;" " height = 10;" " fixed_width = true;" " fixed_height = true;" " }" " ok_only;" "}") (write-line str f)) (setq f (close f)) ) ) (setq dcl (load_dialog filename)) (if (not (new_dialog "main" dcl)) (progn (prompt "\nDCl not found!") (exit) ) ) (start_list "list")(mapcar 'add_list lst)(end_list) (start_dialog) (unload_dialog dcl) (princ) ) Edited November 6, 2010 by Lt Dan's legs Quote
Lee Mac Posted November 5, 2010 Posted November 5, 2010 FYI: there is no start_dialog call, this will cause the dialog to appear but the user to have no way to terminate it without terminating AutoCAD through the Task manager... Quote
Lee Mac Posted November 6, 2010 Posted November 6, 2010 Had fun with this one LISP (change red part to suit) (defun c:Tip! ( / *error* LM:WriteDCL tipfile tips tip SavePath dcfname dcHan ) (vl-load-com) ;; © Lee Mac 2010 [color=red][b] ;; Tip of the Day Source File (setq tipfile "C:\\Tips.txt")[/b][/color] (defun *error* ( msg ) (if ofile (close ofile)) (if dcHan (unload_dialog dcHan)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (defun LM:WriteDCL ( filename / ofile ) (cond ( (findfile filename) ) ( (setq ofile (open filename "w")) (foreach str '("tip : dialog { label = \"Tip of the Day\";" " spacer;" " : list_box { key = \"list\"; width = 60; height = 20; fixed_width = true; fixed_height = true; }" " spacer;" " ok_only;" "}" ) (write-line str ofile) ) (setq ofile (close ofile)) (while (not (findfile filename))) filename ) ) ) (cond ( (not (setq tipfile (findfile tipfile))) (princ "\n** Tip File not Found **") ) ( (not (setq tips (GetTips tipfile))) (princ "\n** No Tips Found **") ) ( (not (vl-file-directory-p (setq SavePath (LM:GetSavePath)))) (princ "\n** Save Path not Valid **") ) ( (not (LM:WriteDCL (setq dcfname (strcat SavePath "\\LMAC_TipoftheDay.dcl")))) (princ "\n** DCL could not be written **") ) ( (<= (setq dcHan (load_dialog dcfname)) 0) (princ "\n** DCL could not be found **") ) ( (not (new_dialog "tip" dcHan)) (princ "\n** DCL could not be loaded **") ) (t (setq tip (nth (rand 0 (1- (length tips))) tips)) (start_list "list") (mapcar 'add_list tip) (end_list) (start_dialog) (setq dcHan (unload_dialog dcHan)) ) ) (princ) ) (defun LM:GetSavePath ( / tmp ) (cond ( (setq tmp (getvar 'ROAMABLEROOTPREFIX)) (or (eq "\\" (substr tmp (strlen tmp))) (setq tmp (strcat tmp "\\")) ) (strcat tmp "Support") ) ( (setq tmp (findfile "ACAD.pat")) (setq tmp (vl-filename-directory tmp)) (and (eq "\\" (substr tmp (strlen tmp))) (setq tmp (substr tmp (1- (strlen tmp)))) ) tmp ) ) ) (defun GetTips ( fname / ofile nl lst sub ) (cond ( (setq ofile (open fname "r")) (while (setq nl (read-line ofile)) (if (eq "***" nl) (setq lst (cons (reverse sub) lst) sub nil) (setq sub (cons nl sub)) ) ) (reverse (setq ofile (close ofile) lst (cons (reverse sub) lst))) ) ) ) ;; SMadsen (defun rand ( minN maxN / rnd ) (defun rnd ( / modulus multiplier increment ) (if (not seed) (setq seed (getvar 'DATE))) (setq modulus 65536 multiplier 25173 increment 13849) (setq seed (rem (+ (* multiplier seed) increment) modulus)) (/ seed modulus) ) (fix (+ minN (* (rnd) (- (1+ maxN) minN)))) ) Tips! Separate each tip with *** Tip Number 1 Before starting work, be sure to turn computer on. *** Tip Number 2 Make sure coffee cup is full. *** Lee Mac's Bonus Tip Learn to write AutoLISP Tips are selected at random Quote
Lt Dan's legs Posted November 6, 2010 Posted November 6, 2010 thanks. I actually modified mine from a previous post for vector_image. I just removed too many things Quote
sharpooth Posted November 6, 2010 Author Posted November 6, 2010 Thank you Lee! Your idea it is working very well last sentance from Tips is very important Thank you Lt Dan's legs! Quote
Lee Mac Posted November 6, 2010 Posted November 6, 2010 Thank you Lee! Your idea it is working very well last sentance from Tips is very important Thank you Lt Dan's legs! Excellent - I'm glad you like it Now its up to you to populate the Tips How many are you going to make? Quote
Lt Dan's legs Posted November 6, 2010 Posted November 6, 2010 last sentance from Tips is very important Thank you Lt Dan's legs! No problem *Warning* Once you start writing programs you may not be able to stop. Quote
sharpooth Posted November 6, 2010 Author Posted November 6, 2010 Excellent - I'm glad you like it Now its up to you to populate the Tips How many are you going to make? 30 tips. One per day. The tips are very usefully thinks. For example : after working time shut down the computer; after working time shut down the printer; Today is Christmas! tasks for today : 1............... 2............... and so on . Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.