newLISP Fan Club

Forum => newLISP in the real world => Topic started by: alex on May 09, 2007, 12:25:28 PM

Title: Problem with (main-args)/link.lsp
Post by: alex on May 09, 2007, 12:25:28 PM
I have two files:

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

and

;; lsp2exe.lsp
(load "link.lsp")
(link "newlisp.exe" "_test.exe" "_test.lsp")
(exit)

and I have input/output:

S:tempnewlispbin>newlisp lsp2exe.lsp

S:tempnewlispbin>newlisp _test.lsp 1 2 3 4 5
("newlisp" "_test.lsp" "1" "2" "3" "4" "5")

S:tempnewlispbin>_test.exe 1 2 3 4 5
("_test.exe" "1" "2" "3" "4" "5")

S:tempnewlispbin>


Such difference is not good(IMHO)...



Your opinion?
Title:
Post by: HPW on May 09, 2007, 12:43:06 PM
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.
Title:
Post by: Lutz on May 09, 2007, 12:55:43 PM
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:


(if (ends-with (main-args 0) "text.exe") ...)
Title:
Post by: alex on May 09, 2007, 12:56:29 PM
We have such problem in Linux?
Title:
Post by: Lutz on May 09, 2007, 01:00:26 PM
Yes,  it is the same on all platforms. See my edited previous post how to code for this.



Lutz
Title:
Post by: alex on May 09, 2007, 04:57:37 PM
I feel, that I need in one simple function - (os-args) !



;; _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:


S:tempnewlispbin>newlisp _test.lsp 1 2 3 4 5
("1" "2" "3" "4" "5")

S:tempnewlispbin>_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?