Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using (startapp)

10 REPLIES 10
Reply
Message 1 of 11
southie
985 Views, 10 Replies

Using (startapp)

Hi Gang,

 

Is the a way when calling (startapp "c:\\windows\\notepad.exe" "txtout2.txt")

 to have the program pause until you saved changes to the file? Thanks

 

Southie

 

10 REPLIES 10
Message 2 of 11
southie
in reply to: southie

Wanted no user intervention but looks like a no go.  Went with an (alert ).

Message 3 of 11
alanjt_
in reply to: southie

Could you elaborate more? I'm a little confused on what exactly you're trying to accomplish.

Message 4 of 11
southie
in reply to: southie

Thanks for the interest Alan

 

For instance when i run sniip below unless i use some kind of pause thing  the txtout1.txt output file would have already been opened read and wrote out to output1.txt before saving txtout1.txt in notepad.

 

(setq f (open "output1.txt" "w"))

(setq chkstr (startapp "c:\\windows\\notepad.exe" "txtout1.txt"));make changes to file then save

(alert "You have completed and Saved Changes!")

(setq ff (open "txtout1.txt" "r"))
(while (setq a (read-line ff))
(write-line a f)
)

(close ff)

(close f)

 

Message 5 of 11
martti.halminen
in reply to: southie

For that you would need to be able to add something like an AutoCAD reactor to Notepad's save functionality, and get it to send a message to AutoCAD. Pretty much impossible for closed-source programs with no API for the purpose.

 

Far easier would be to make AutoCAD wait until the user closes the external program, that wouldn't need any access to its internals.

Can't do that with STARTAPP, but take a look at the dos_exewait function in DOSlib.

 

--

Message 6 of 11
devitg
in reply to: southie

Try it . It will open , let you made change in notepad , save in the new file , and open again
Message 7 of 11
southie
in reply to: southie

Thanks for responses guys

 

Marti can't use dol_lib by contract to many different users.

 

Dev tried your sugestion but it did not work when i commented out the ;(alert "You have completed and Saved Changes!").

Was hoping for no user intervention.  see below  and again thanks

 

 

(setq ff (open "txtout1.txt" "w"))
(write-line "THIS LINE OF TEXT IS HERE TO ACT LIKE A MARGIN FOR NOTE INPUT." ff)
(close ff)

 

(setq f (open "output1.txt" "w"))
 
(setq chkstr (startapp "c:\\windows\\notepad.exe" (findfile "txtout1.txt")));make changes to file then save
;(alert "You have completed and Saved Changes!")
(setq ff (open (findfile "txtout1.txt") "r"))
(while (setq a (read-line ff))
(write-line a f)
)
(close ff)
(close f)

(startapp "c:\\windows\\notepad.exe" (findfile "txtout1.txt"))

Message 8 of 11
devitg
in reply to: southie

(setq ff (open "txtout1.txt" "w"))
(write-line "THIS LINE OF TEXT IS HERE TO ACT LIKE A MARGIN FOR NOTE INPUT." ff)
(close ff)
 
(setq f (open "output1.txt" "a"))
 
(setq chkstr (startapp "c:\\windows\\notepad.exe" (findfile "txtout1.txt")));make changes to file then save
;(alert "You have completed and Saved Changes!")
(Close f)

(setq f (open "output1.txt" "a"))


(setq ff (open (findfile "txtout1.txt") "r"))
(while (setq a (read-line ff))
(write-line a f)
)
(close ff)
(close f)
(startapp "c:\\windows\\notepad.exe" (findfile "txtout1.txt"))

Try this way  NOTE the A instead of W 

Message 9 of 11
southie
in reply to: southie

Dev

 

Tried new solution same result. Unfortunatley I think Martti is correct on this. 

 

Southie

Message 10 of 11
devitg
in reply to: southie

Maybe I can not understand your query.

Find attached 2 files

 

make-file , use only once

 

use

 

make-change-at-notepad

 

to make the changes

Message 11 of 11
martti.halminen
in reply to: southie


@southie wrote:

Thanks for responses guys

 

Marti can't use dol_lib by contract to many different users.

 

Another way, if you don't want to use DOSlib, would be to build a busy-wait loop after the STARTAPP call, watching the timestamp of the txtout.txt file.

http://en.wikipedia.org/wiki/Busy_waiting

- better add a timeout, if the user never saves the file...

 

--

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost