Autolisp FAS file loads corrupt code for some users.

Autolisp FAS file loads corrupt code for some users.

mmitchellH6TRW
Enthusiast Enthusiast
2.697 Vistas
18 Respuestas
Mensaje 1 de 19

Autolisp FAS file loads corrupt code for some users.

mmitchellH6TRW
Enthusiast
Enthusiast

From Alex (my manager)
"Additionally, how come we are having so many issues with the lisp routine? Is it because of the files we are loading or is it because of the way the lisp was written? "

 

From me
"Nether. But I don't know how to fix it yet. I have checked the code. It is all good. I have started compiling the code into machine code before publishing it. This helped with most of the apps. But it still had this random anomaly. I wrote an app to load the machine code, rather than loading them directly using ACAD's auto app loader. This has proven the best so far. At least on my machine they load every time correctly. But Amanda's machine doesn't run them without error...... I find nothing on line, so I'm going to open a new question on the ACAD form. We'll see."

 

This random anomaly:  the code loads, It starts to run normally, but then gives a "too few arguments" error. This is usually the case when the selected csv file (input file) is not formatted properly. However, I run the same file against the same FAS and all I get is "1 objects placed from FDC_TEMP" (it ran successfully). 

 

The reason I went to FAS app files was the the lsp code wasn't running without errors when all the code was good.
The reason I went to 

 

;; loadLAapps.lsp Ver 1.1					
;;											
;; Loads the Cerritos LA apps:				
;; DISBLK									
;; SELDIS									
;; UTLBLK									
;; get_ll									
;;											
;; Mark Mitchell ADP-Resources 4/9/2020		
;;											

(princ "\n")
(autoload "DISBLK.fas" '("DISBLK"))
(autoload "SELDIS.fas" '("SELDIS"))
(autoload "UTLBLK.fas" '("UTLBLK"))
(autoload "get_ll.lsp" '("get_ll"))
(princ)

 

was that the code from a freshly load disblk would run as if it was seldis and then ab-end after reading the second record.
(get_ll.lsp is small, short code. No problems. gets lat and long for a selected point. So size of file matters.)

Since I started using loadLAapps.lsp I haven't had any problems running the apps. Neither have three other drafters. Yet, Amanda calls me up today....  She can't get the UTLBLK app to run. It asks for a file, she double clicks the desired file.... "too few arguments" error. I run UTLBLK on my machine selecting the same file....  "1 objects placed from FDC_TEMP" (it ran successfully). 

The only difference in our installations is Amanda runs ACAD Map2019, I'm running ACAD Map 2021. But this code should run on Map2014. There's nothing fancy in it.

 

Any help will be appreciated.  Sorry for the rambling request.

link to files  (right-click open link in new tab)

This link is to a share on https://adpresources-my.sharepoint.com/

0 Me gusta
Soluciones aceptadas (1)
2.698 Vistas
18 Respuestas
Respuestas (18)
Mensaje 2 de 19

Sea-Haven
Mentor
Mentor

Does the filename have spaces in it ? Or  is it only very std characters ie a-z 1-0 _- or does it have "." in it ?

 

Can you run code on same file with same directory naming again directories with spaces in the names ?

0 Me gusta
Mensaje 3 de 19

dlanorh
Advisor
Advisor

Random Thoughts.

With it working on some workstations and not others it suggests either the lisps don't ensure the correct system variables are set and/or some system variables are different between workstations.

 

Do the lisps contain global variables?

Have you tried compiling to "fas" on the machines where it doesn't work, as this could be a windows problem?

If the lisp works in the majority of cases does it work on all workstations in "lsp" format?

I am not one of the robots you're looking for

Mensaje 4 de 19

cadffm
Consultant
Consultant

The first step (i can not read about in your post) is:

load your source lsp files on this machine, let Amanda try again

(! = Amandas Windows login, Amandas MAP Profile, not your Account)

It is working with manually loaded lsp files or not? I miss this information.

 

If not:

Second step is to debug the program and AutoCAD(vlide) will show you where the problem is,

then you can find the source issue.

Sebastian

0 Me gusta
Mensaje 5 de 19

mmitchellH6TRW
Enthusiast
Enthusiast

I will look into this.

0 Me gusta
Mensaje 6 de 19

mmitchellH6TRW
Enthusiast
Enthusiast

Z:\dropbox\ADP\CableCom\CA\South LA\Cerritos Hub\Cerritos Segments\FDH H1015\FIELD WORK\GIS 1015 4-14-2020\FDC_TEMP.csv

This is the input file for both drafters. For one the app works. For the other after the file is read it fails with error: 
"too few arguments"

0 Me gusta
Mensaje 7 de 19

mmitchellH6TRW
Enthusiast
Enthusiast

I have requested Amanda to load UTLBLK.LSP . Waiting for her to respond.
In the mean time here is my error handling routine: 

;;; Error handling		
	(setq error *error*)
	;;				
	;; Define error handler	
	;;				
	(defun *error* (msg)
		(alert msg)
		(setq *error* error)
;;; End of program
		(ADP:end_prog ctbl fnid fn)
		;; takes  blk_cnt file_id file_name						
		;; closes file, collects garbage, Marks undo,					
		;; sets dir to fn path, propagates dir to all drawings in this session	
		;; turns command echo back on and prints # of blocks				
		;; returns quite								
		(alert "UTLBLK did not end normally.")
		(vl-exit-with-value nil)
	)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; End of program  - Mark Mitchell ADP-Resources  2020			
;; takes  blk_cnt file_id file_name					
;; closes file, collects garbage, Marks undo,				
;; sets dir to fn path, propagates dir to all drawings in this session	
;; turns command echo back on and prints # of blocks			
;; returns quite							
(defun ADP:end_prog	(blk_cnt fnid fn /)
	(close fnid)						; Close File
	(vl-doc-set 'dir (vl-filename-directory fn))
										; strip out directory name from file name and set to current drawings namespace
	(vl-propagate 'dir)					; propagate dirctory during current session
	(command-s "_.undo" "Mark")			; Mark Undo file     Undo Back to Restore
	(gc)								; garbage collection
	(setvar "CMDECHO" 1)				; Turn on command echo
	(princ "\n")
	(princ (strcat (itoa blk_cnt)
				   " objects placed from "
				   (vl-filename-base fn)
		   )
	)									; print # of blocks placed
	(princ)								; return quite
)

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

How do I get vlide to till me where the error is? I just get the error. (Or Amanda does. I get clean execution of the app when I run it.)

0 Me gusta
Mensaje 8 de 19

cadffm
Consultant
Consultant

1. Independent of your current issue: Dropbox is not the perfect place for files

if you have trouble and trying to find the issue.

(i guess it is not just a normal folder with the name dropbox, i guess it is a dropbox- synced folder)

 

2. Do you know what "debugging" means?

   You can do in manually by adding Alerts or Prints and if you found the part with the issue you can

   find the exact problem by copy/paste the line step by step to Acad.

 

  VLide have some good debug features like: Go thru the code STEP by STEP,

  you have the option if you want to do that manually by your click or like an animation,

  there is also a feature in Vlide that the code stops at the error point.. this helps to finde the problem.

 

But it is too difficult for me to explain in English (time) and you can also find everything in the help, in the forum or maybe on Youtube.

You just need to search and take your time.
Two links to start with:

 

Your Help[F1]

To Start Debugging a Program (Visual LISP IDE)

 

LM

Debugging Code with the Visual LISP IDE

 

Sebastian

0 Me gusta
Mensaje 9 de 19

mmitchellH6TRW
Enthusiast
Enthusiast

Amanda load the the lisp 

UTLBLK.lsp
using appload.
Then gets the error "Unknown command UTLBLK " at the acad command line.
I ask her to load it one more time. She got offended that I didn't trust her to load it the first time.
She still reloaded it.
Same response.
 
0 Me gusta
Mensaje 10 de 19

mmitchellH6TRW
Enthusiast
Enthusiast

 
(/dropbox/) is a renominate from a long time ago. It is all on a local server now.

The code works for me. Totally debugged. But for other drafters it is just frustration. I only have two out of six that can run my code. And from day to day. Totally random wither it will work today. They are revolting and giving up on the process all together.

0 Me gusta
Mensaje 11 de 19

mmitchellH6TRW
Enthusiast
Enthusiast
From our office chat:
I am running 2021 so I am out of the test. But what is different about Aloura's installation of 2019 that her's works?
(all the others seem to be failing)
This is from Ron Harman Level 10 on AutoDesk's Knowledge Network:   (I'm level 6)
"With it working on some workstations and not others it suggests either the lisps don't ensure the correct system variables are set and/or some system variables are different between workstations." I change vary few system variables with code. But perhaps I should but I haven't a clue to which variables might be causing these problems.
(problems: appload say that the code loads. .fas or .lsp) but doesn't recognize the command. (i.e. "Unknown command UTLBLK")
So what system variables could cause this situation?
0 Me gusta
Mensaje 12 de 19

mmitchellH6TRW
Enthusiast
Enthusiast

Thank you. After getting past the "but I know how to debug".....  I looked at the very good references that you provided.
Although they don't help the current dilemma, they will help with debugging in the future. In particular the Break On Error feature.

0 Me gusta
Mensaje 13 de 19

dlanorh
Advisor
Advisor

@mmitchellH6TRW wrote:
(problems: appload say that the code loads. .fas or .lsp) but doesn't recognize the command. (i.e. "Unknown command UTLBLK")
So what system variables could cause this situation?

Off the top of my head, there is the "trustedpaths" system variable. You can load but not run lisps/fas/vlx from a source that is not listed in the trusted paths

 

This should help in that respect

 

 

 

;19.1 is AutoCAD 2013 when these were introduced
; NOTE the semicolon on the end of the path
(if (>= (float (getvar "ACADVER")) 19.1) (setvar 'trustedpaths (strcat (getvar 'trustedpaths) "your_path;")))

 

 

 

There is a difference between an application loading and an application running. I can load a lisp file but it won't run if there is an error in the code. "Unknown command UTLBLK" is normally an indicator that this is happening with a lisp file, but as I rarely compile my lisps I couldn't say what would be causing the error when compiled to fas.

 

There have also been a spate of registry keys pointing to the vl.arx going missing. Test if

 

 

 

(vlax-ename->vla-object (car (entsel "\nSelect an entity : ")))

 

 

 

produces an error on the machines that don't work

 

check the raw lisp code that all apps start with (defun c: )

I am not one of the robots you're looking for

Mensaje 14 de 19

john.uhden
Mentor
Mentor

Ya got me.  The only strange thing I see is the ancient usage of a global error handler and resetting it.  Why not localize *error*?

John F. Uhden

0 Me gusta
Mensaje 15 de 19

mmitchellH6TRW
Enthusiast
Enthusiast

Would you give me an example of a better error handler? What do you mean "localize *error*"?

0 Me gusta
Mensaje 16 de 19

mmitchellH6TRW
Enthusiast
Enthusiast

Thank you, I will try these tomorrow morning.

0 Me gusta
Mensaje 17 de 19

Sea-Haven
Mentor
Mentor

To compare vars a bit rough but use logfile, set a path where to save file, then logfileon 

setvar ? *

logfileoff

You should have a log file now in the directory and it will be drawingname_xxxxx .log.

Drawing2_1751b065d.log

 

Get the log from both computers open both in separate notepad scroll both yes its a pain but can see the different values may need to check help for variable or use "Express, Tools, System variable editor" to work out what it does.

 

I have had these problems and they can be time consuming. 

 

If you use VLIDE you can see all the defuns inside the code it may be looking for some other lisp that has not been auto loaded check appload go through the list of lisps loaded. Look in history etc both pc's.

 

lee-mac.com has a good VLIDE tutorial. Break on error should reveal the problem. You can inspect this error,

 

As a ruthless step remove all error checking defuns this way it will crash and not be error captured.

0 Me gusta
Mensaje 18 de 19

john.uhden
Mentor
Mentor
;; Example of localized *error* function:
(defun c:whatever ( / *error* this that etc)
(defun *error* (error)
;; clean up
(cond
((not error))
((wcmatch (strcase error) "*QUIT*,*CANCEL*"))
(princ (strcat "\nERROR: " error))
)
(princ)
)
;; Do your program stuff here
(*error* nil)
)

John F. Uhden

0 Me gusta
Mensaje 19 de 19

mmitchellH6TRW
Enthusiast
Enthusiast
Solución aceptada

All of these lisp routines share code. Some with modifications. But.... the same subroutine names. 
I changed the subroutine names to be unique to each lisp. Vola.... No code "overloading" anothers. 

0 Me gusta