Jump to content
Ahankhah

Ask the name of running program!

Recommended Posts

Ahankhah

Hi CADTutormates,

is it possible to know the name and location of current code by itself? If yes, how?

For example, if the loaded program is: "c:/MyFolder/Myprogram.fas", needed to find strings: "c:/MyFolder/" and "Myprogram.fas"?

Share this post


Link to post
Share on other sites
LibertyOne

If you run the command "_APPLOAD" the dialog shows a list of all loaded *.lsp, *.arx, *.fas, etc. files. Getting that information in the form that you need my be a bit difficult.

Share this post


Link to post
Share on other sites
MSasu

The list of currently loaded AutoLISP files can be retrieved using the dos_lisplist function from DOSLib pack. Also the CMDACTIVE system variable will tell you the active action (however if an AutoLISP routine is the active one this is visible only from an ARX tool). Not sure if those may help you.

 

Regards,

Mircea

Share this post


Link to post
Share on other sites
Ahankhah
If you run the command "_APPLOAD" the dialog shows a list of all loaded *.lsp, *.arx, *.fas, etc. files. Getting that information in the form that you need my be a bit difficult.

LibertyOne,

Maybe the way "_.APPLOAD" gets and keeps in mind the name and path of applications (programs) is good to achieve the goal:), but how to do that by coding in AutoLISP:huh:?

Share this post


Link to post
Share on other sites
Ahankhah
The list of currently loaded AutoLISP files can be retrieved using the dos_lisplist function from DOSLib pack.

Mircea, when I want to find "DOSLib18.arx" in the directory of my code, the paradox happens. First step is finding the program like one mentioned to load it via my code. How this step should be done:unsure:?

Share this post


Link to post
Share on other sites
Lee Mac

findfile?

 

..

Share this post


Link to post
Share on other sites
Ahankhah
findfile?

 

..

Of course Lee,

when the file is in the sme folder of current code, but the folder isn't in the search path of (findfile).

Share this post


Link to post
Share on other sites
alanjt

Maybe you need to start organizing things a little better. blow%20up%20his%20ass.gif

Share this post


Link to post
Share on other sites
BlackBox
Of course Lee,

when the file is in the sme folder of current code, but the folder isn't in the search path of (findfile).

 

Ahankhah, consider how much less typing you'd do, if you no longer needed (most?) hard-coded file paths in your code, which would also make your code easier to maintain if / when paths change... PLUS the added benefit of using findfile... sounds like a win-win-win to me.

Share this post


Link to post
Share on other sites
alanjt
Ahankhah, consider how much less typing you'd do, if you no longer needed (most?) hard-coded file paths in your code, which would also make your code easier to maintain if / when paths change... PLUS the added benefit of using findfile... sounds like a win-win-win to me.

Agreed.

(load "file" nil) is a lot less work than (load "c:\\folder\\folder\\folder\\folder\\folder\\folder\\folder\\file" nil)

Share this post


Link to post
Share on other sites
Ahankhah

It shows I am not so clear, perhaps for my bad explanation.

Assume that you have a code (I name it "main program"). The "main program" needs to load another program ("reference program"). Both "main program" and "reference program" are located in the same folder, regardless of folder's name and location. The problem is I want to find "reference program" while (findfile) can't find it as well refering it without clarifying the path does nothing.

I hope this time I am clear enough. banghead.gif

Share this post


Link to post
Share on other sites
LibertyOne
Hi CADTutormates,

is it possible to know the name and location of current code by itself? If yes, how?

For example, if the loaded program is: "c:/MyFolder/Myprogram.fas", needed to find strings: "c:/MyFolder/" and "Myprogram.fas"?

 

I'm curious, what would be the advantage of knowing this? I mean, knowing what apps are loaded is one thing. But asking the location from where the app is loaded may not be relevant. It's like waving down a taxicab and after getting in, asking the driver from where he just arrived.

Share this post


Link to post
Share on other sites
LibertyOne
It shows I am not so clear, perhaps for my bad explanation.

Assume that you have a code (I name it "main program"). The "main program" needs to load another program ("reference program"). Both "main program" and "reference program" are located in the same folder, regardless of folder's name and location. The problem is I want to find "reference program" while (findfile) can't find it as well refering it without clarifying the path does nothing.

I hope this time I am clear enough. banghead.gif

 

ok, I would go about doing this a completely different way. I would first check if the "reference_program" was loaded or not.

(atoms-family 1 "reference_program")

If it's not loaded then I would load it knowing where the reference program is saved.

Share this post


Link to post
Share on other sites
Ahankhah
ok, I would go about doing this a completely different way. I would first check if the "reference_program" was loaded or not.
(atoms-family 1 "reference_program")

If it's not loaded then I would load it knowing where the reference program is saved.

In this code:

(atoms-family 1 '("reference-program"))

"reference-program" refers to a function/command/variable and not a file.

Share this post


Link to post
Share on other sites
BlackBox
In this code:

(atoms-family 1 '("reference-program"))

"reference-program" refers to a function/command/variable and not a file.

 

If you want to (I'll use a different word) *identify* the name of a sub-function called from a primary function, then in a new / blank file in VLIDE:

 

(defun c:FOO ()
 [color=red][b]([/b][/color]<PrimaryFunction>)) [color=red]; <- Red paren represents breakpoint[/color]
(c:FOO)

 

... and load the above code. When the VLIDE breaks at the leading paren notated above, simply step through the code using F8, one line at a time. This *should* open the resultant / dependent routines (assuming they're .LSP?), and subsequent steps (pressing F8 ) *should* allow you to step through the newly opened / dependent sub-functions being called.

 

I'm still completely perplexed why you are pursuing this, given that you already know that the sub-function ("reference program") resides within the same directory. Furthermore, unless the "main program" is hard-coded to load the "reference program", the latter is being loaded by another routine, perhaps by ACADDOC.lsp? I see you're using 2012; perhaps this is the result of your using the *autoload* folder?

Share this post


Link to post
Share on other sites
Lee Mac

When a file is loaded into memory, you only have access to the defined symbols in the document namespace, not the file from which they were loaded.

Share this post


Link to post
Share on other sites
alanjt
When a file is loaded into memory, you only have access to the defined symbols in the document namespace, not the file from which they were loaded.

Precisely. Hell, you can copy a LISP routine and paste it directly into the command line.

Share this post


Link to post
Share on other sites
BlackBox

:lol:

 

polls_purplesquirrel_0626_533310_answer_1_xlarge.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...