可能是方法有问题,把odcl文件存为lsp虽然可以编译进vlx,但是这样作的后果是程序运行时找不到ODCL文件,所以出错。
一个笨的方法是把ODCL的后缀名改为*.txt的形式,然后打包进vlx中,程序运行时还原ODCL文件到指定路径中,然后加载,应该可以正常运行了。具体怎么还原ODCL文件,可以参考下面的代码。
这个代码是从其他论坛找来的。 - ;;|因为用vl-get-resource读出的文本是用"\r\n"(分行回车)符分隔的,因此可以利用zhy_string_tok函数来生成字符串表。
- 然后根据表的内容来复原对话框。
- |;;
- (defun odc_make (odc_name odc_txt / fn fn2 fn_lst n m fn_txt)
- (setq fn2 (open odc_name "w"));odc_name为要生成的对话框
- (setq fn (vl-get-resource odc_txt));odc_txt为打包到vlx中的文本名,(不要扩展名)
- (strlen fn)
- (setq fn_lst (zhy_string_tok fn "\r\n"));根据读出的文本生成字符串表
- (setq n (length fn_lst))
- (setq m 0)
- (while (< m n)
- (setq fn_txt (nth m fn_lst))
- (write-line fn_txt fn2)
- (setq m (1+ m))
- )
- (close fn2)
- )
- (defun zhy_string_tok (sstring sstr / n1 n2 m2 str_1)
- (setq string_list '())
- (setq n1 (strlen sstring))
- (setq n2 (strlen sstr))
- (while (setq m2 (vl-string-search sstr sstring))
- (setq str_1 (substr sstring 1 m2))
- (setq sstring (substr sstring (+ 1 m2 n2)))
- (if (/= str_1 "")
- (setq string_list (cons str_1 string_list))
- )
- (if (= (substr sstring 1 n2) sstr)
- (setq string_list (cons "" string_list))
- )
- )
- (if (/= sstring "")
- (setq string_list (cons sstring string_list))
- )
- (reverse string_list)
- )
|