error: too many arguments with user defined function

error: too many arguments with user defined function

Anonymous
Not applicable
870 Views
3 Replies
Message 1 of 4

error: too many arguments with user defined function

Anonymous
Not applicable

When I run this load file in the debugger and I run:

(LOADFILES "Z:\\Emmaus\\Auto CAD\\Emmaus-Lisps\\" "C:\\Emmaus-Lisps\\")
 
I immediately get an error that says "error: too many arguments". it doesn't even reach the first breakpoint line in the function. The function definition seems to only have two arguments so I am not sure why that is. 
 
(defun loadFiles ( / srcDir destDir)
  (setq filesList(list  "bom.lsp"      ; list of files to copy over.
                        "singleLine.lsp"
                        "smallUtilities.lsp"))

  (setq loadLogFile (open (strcat destDir "load.log") "a"))
  (write-line "Entered load.lsp" loadLogFile)

  (if (/= foundSrcDrive "?")
    (foreach flTmp filesList
      (progn
        (setq srcFile  (strcat srcDir flTmp))
        (setq destFile (strcat destDir flTmp))
        (setq ret (vl-file-delete destFile))                       ; must delete the local copy before copying
        (setq ret (vl-file-copy srcFile destFile))                 ; copy from the server to the local PC. Save the copy function return code.
        (if (= nil ret)                                            ; if the copy failed
          (write-line (strcat "Warning or Error: Did not copy: " srcFile) loadLogFile) ; warning for acad.lsp, error for anything else
          (progn
            (write-line (strcat "Copied " srcFile " to " destFile) loadLogFile)
            (load destFile (write-line (strcat "Failed to load: " destfile)))
          ) ; else success
        )
      )
    )
    ; else the test file was not found on the server                                                    
    (write-line (strcat "ERROR: Did not find test file: " (strcat srcDirNoDrv testFile) " to copy") loadLogFile)
  )

  (close loadLogFile)
)
0 Likes
Accepted solutions (1)
871 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

@Anonymous wrote:

When I run this load file in the debugger and I run:

(LOADFILES "Z:\\Emmaus\\Auto CAD\\Emmaus-Lisps\\" "C:\\Emmaus-Lisps\\")
 
I immediately get an error that says "error: too many arguments". it doesn't even reach the first breakpoint line in the function. The function definition seems to only have two arguments so I am not sure why that is. 
 
(defun loadFiles ( / srcDir destDir) ; remove the slash
  (setq filesList(list  "bom.lsp"      ; list of files to copy over.
                        "singleLine.lsp"
                        "smallUtilities.lsp"))

  (setq loadLogFile (open (strcat destDir "load.log") "a"))
  (write-line "Entered load.lsp" loadLogFile)

  (if (/= foundSrcDrive "?")
    (foreach flTmp filesList
      (progn
        (setq srcFile  (strcat srcDir flTmp))
        (setq destFile (strcat destDir flTmp))
        (setq ret (vl-file-delete destFile))                       ; must delete the local copy before copying
        (setq ret (vl-file-copy srcFile destFile))                 ; copy from the server to the local PC. Save the copy function return code.
        (if (= nil ret)                                            ; if the copy failed
          (write-line (strcat "Warning or Error: Did not copy: " srcFile) loadLogFile) ; warning for acad.lsp, error for anything else
          (progn
            (write-line (strcat "Copied " srcFile " to " destFile) loadLogFile)
            (load destFile (write-line (strcat "Failed to load: " destfile)))
          ) ; else success
        )
      )
    )
    ; else the test file was not found on the server                                                    
    (write-line (strcat "ERROR: Did not find test file: " (strcat srcDirNoDrv testFile) " to copy") loadLogFile)
  )

  (close loadLogFile)
)

 

0 Likes
Message 3 of 4

Anonymous
Not applicable
As a follow up question. Why does this not work? does the slash not separate local and global variables? Also when I have a definition that only has the slash, it will still work.
0 Likes
Message 4 of 4

ВeekeeCZ
Consultant
Consultant

It separates arguments from local variables. Globals are not declared. See HELP HERE 

Yes, it will... but you can't call your func with arguments as (loadfiles path1 path2).

 

0 Likes