Author Topic: will someone be kind enough to tell me where im going wrong and how to fix this  (Read 2039 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
i get this error message
; error: no function definition: OPFIL

aside from that it works the way i want to.
what im attempting to do is to place a button to allow me to open and select another file to be read.
any help is appreciated.

here is the lisp code
Code: [Select]
(setq fDATE (menucmd "M=$(edtime,$(getvar,date), MON DD YYYY)"))
(SETQ HFILE (STRCAT "c:\\DWG-History" FDATE ".txt"))

(setq file1 (open HFILE "r"))
(setq lista (list))
(while (setq rl1 (read-line file1))
(setq lista (append lista (list rl1)))
);end while
(close file1)
(setq lista (reverse lista))
(setq NT 0)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq dclid (load_dialog "History.dcl"))
  (new_dialog "History" dclid)
  (defun edit_action1 (val)
  (setq NT val)
  )
  (action_tile "Thelist" "(edit_action1 $value)")
  (action_tile "cancel" "(done_dialog)(exit)")
  (action_tile "page2" "(opfil)")
  (start_list "Thelist")
(setq counta 0)
(while (setq wl1 (nth counta lista))
(add_list wl1)
(setq counta (+ counta 1))
);end while
  (end_list)
  (start_dialog)
  (done_dialog)
  (unload_dialog dclid)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



(command "._VBASTMT" (strcat "AcadApplication.Documents.Open \"" (nth (atoi NT) lista) "\""))
(princ)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun opfil ()
(setq hfile nil)
(setq HFILE (getfiled "Select File" HFILE "txt" 0))
(setq file1 (open HFILE "r"))
(setq lista (list))
(while (setq rl1 (read-line file1))
(setq lista (append lista (list rl1)))
);end while
(close file1)
(setq lista (reverse lista))

)

here is the DCL code
Code: [Select]
History : dialog {
label = " History- Double Click ";
: list_box {
alignment = left;
key = "Thelist";
width = 50;
                height = 30;
edit_width = 100;
}

spacer;
: row {
fixed_width = true;
alignment = centered;
: button {
width = 12;
label = "OK";
key = "accept";
is_default = true;
}
: button {
width = 12;
label = "Cancel";
key = "cancel";
                        is_default = true;
is_cancel = true;
}
: button {
width = 12;
label = "Open";
key = "page2";
                        is_default = true;
}

}
spacer;
}

uncoolperson

  • Guest
get your defun for that function up above where it is called (the function never gets a chance to load)

uncoolperson

  • Guest
or you could include the rest into a seperate function

(defun C:everythingelse () <-- a 'c:' here so it's also a command
everything else goes here
)

(def OPFIL ()

)

xshrimp

  • Mosquito
  • Posts: 14
Quote
(defun opfil ()
(setq hfile nil)
(setq HFILE (getfiled "Select File" HFILE "txt" 0))
.........
(getfiled "Select File" HFILE "txt" 0)

HFILE--------- String is necessary not nil

abc

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Welcome to TheSwamp, xshrimp.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

andrew_nao

  • Guest
get your defun for that function up above where it is called (the function never gets a chance to load)

doh! its always something stupid with me
your help is much appreciated

thank you also to shrimp i didnt even notice that line in there