Jump to content




closing a program when finished


5 replies to this topic

#1 DusterTheFirst

  • Members
  • 40 posts

Posted 23 June 2016 - 11:31 AM

i have a program that periodicly opens this:
local todofile = fs.open("disk/todo.txt", "r")
local todo = peripheral.wrap("monitor_9")
todo.setCursorPos(1,2)
local towrite = todofile.readAll()
todofile.close()
todo.write(towrite)
[/CODE]
in multishell and i cant get it to close its tab once it is done. there ends up being many of them just saying press any key to end/close

how would i do this?

#2 Emma

  • Members
  • 216 posts
  • Locationtmpim

Posted 23 June 2016 - 05:34 PM

Not tested, but if it's asking for a key you can give it a fake key press like so:
os.queueEvent("key",42)
That way, the next time os.pullEvent is called it will return a key event for key 42

#3 DusterTheFirst

  • Members
  • 40 posts

Posted 24 June 2016 - 12:59 PM

 Incinirate, on 23 June 2016 - 05:34 PM, said:

Not tested, but if it's asking for a key you can give it a fake key press like so:
os.queueEvent("key",42)
That way, the next time os.pullEvent is called it will return a key event for key 42
i just want the program to terminate itself

#4 CrazedProgrammer

  • Members
  • 495 posts
  • LocationWageningen, The Netherlands

Posted 24 June 2016 - 01:04 PM


return

Edited by CrazedProgrammer, 24 June 2016 - 01:05 PM.


#5 DvgCraft

  • Members
  • 14 posts
  • LocationThe Netherlands

Posted 24 June 2016 - 01:33 PM

Add this code to the end of your program:
os.queueEvent( "myProgramIsFinished" ) --Rename this
sleep( 0 )
multishell.setFocus( multishell.getCurrent() )

And create another program that will execute the other program:
shell.openTab( "path/to/file" )
os.pullEvent( "myProgramIsFinished" ) --Rename this
local currentTab = multishell.getFocus()
sleep( 0 )
multishell.setFocus( currentTab )


#6 DusterTheFirst

  • Members
  • 40 posts

Posted 26 June 2016 - 01:22 AM

thanks

Edited by DusterTheFirst, 26 June 2016 - 01:25 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users