Problem with (main-args)/link.lsp

Q&A's, tips, howto's
Locked
alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Problem with (main-args)/link.lsp

Post by alex »

I have two files:

Code: Select all

;; _test.lsp
(println (main-args))
(exit)
and

Code: Select all

;; lsp2exe.lsp
(load "link.lsp")
(link "newlisp.exe" "_test.exe" "_test.lsp")
(exit)
and I have input/output:

Code: Select all

S:\temp\newlisp\bin>newlisp lsp2exe.lsp

S:\temp\newlisp\bin>newlisp _test.lsp 1 2 3 4 5
("newlisp" "_test.lsp" "1" "2" "3" "4" "5")

S:\temp\newlisp\bin>_test.exe 1 2 3 4 5
("_test.exe" "1" "2" "3" "4" "5")

S:\temp\newlisp\bin>
Such difference is not good(IMHO)...

Your opinion?

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Hm, that are the parameters passed by the OS.
There is no longer a file _test.lsp since there is only the source stream embedded in the exe. And that is used by the special routine for embedded start-souce.

Wait what Lutz will comment.
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Yes, its a linkage of 2 programs newlisp.exe and text.lsp giving you a new one called text.exe. It also makes it transparent for the user who can think of it as one new program.

Thats what the linking is for ;)

Lutz

ps: you could code for this:

Code: Select all

(if (ends-with (main-args 0) "text.exe") ...)
Last edited by Lutz on Wed May 09, 2007 7:59 pm, edited 1 time in total.

alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Post by alex »

We have such problem in Linux?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Yes, it is the same on all platforms. See my edited previous post how to code for this.

Lutz

alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Post by alex »

I feel, that I need in one simple function - (os-args) !

Code: Select all

;; _test.lsp 
(define (os-args , params)
  (set 'params (main-args))
  ((if (starts-with (params 0) "newlisp") 2 1) params)
)
(println (os-args)) 
(exit)
input/output:

Code: Select all

S:\temp\newlisp\bin>newlisp _test.lsp 1 2 3 4 5
("1" "2" "3" "4" "5")

S:\temp\newlisp\bin>_test.exe 1 2 3 4 5
("1" "2" "3" "4" "5")
It is enough for me, but I must remark, that (os-args)
MUST BE IN APPLICATION - NOT IN init.lsp

I feel, that it is not vary good realisation of the function, becase of
name "newlisp" in the body

Can we improve it?

It is good for Linux or not?

Locked