This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Ilikemlp123's profile picture

LSC (Latch) - A Lua based batch system

Started by Ilikemlp123, 12 October 2017 - 11:09 PM
Ilikemlp123 #1
Posted 13 October 2017 - 01:09 AM
if you've ever wanted to have batch files or similar in computercraft OR you clicked on this while browsing programs,
I have just the program
Latch 1.0
Pastebin:uaRxBM0q
how it works:
Latch works by opening the selected file in the filesystem, and reading the lines, then it executes the programs listed in sequential order.
ex: run the code
lsc example
Example Script:

ls
cd ..
cd rom
ls
cd programs
ls
cd ../..
programs
How to write a script(for dummies):
  1. type edit, and choose a filename. press enter
  2. list the programs and their args in sequential order.
  3. press ctrl, then press save
  4. run lsc <script name>

Feel free to write programs to go with this, or even improve on this program's design
known bugs:
after executing, it ALWAYS says file not found

Edit:
Thanks to Luca_S for fixing this bug, and changing the code
Tiedied up the loop a bit and also put the execution of the commands after the reading in, so that commands that take a longer time don't keep the FS handle open.
Also this fixes the File not found bug.

Pastebin: R9K4JHZN

You are free to use this in your Operating system, or in any project you want, feel free to add credit, although i don't require it as long as you don't claim it as your own
Edited on 15 November 2017 - 06:44 PM
Luca_S #2
Posted 21 October 2017 - 07:00 PM
Tiedied up the loop a bit and also put the execution of the commands after the reading in, so that commands that take a longer time don't keep the FS handle open.
Also this fixes the File not found bug.

Pastebin: R9K4JHZN
Edited on 21 October 2017 - 05:00 PM
minebuild02 #3
Posted 25 October 2017 - 04:10 PM
Tiedied up the loop a bit and also put the execution of the commands after the reading in, so that commands that take a longer time don't keep the FS handle open.
Also this fixes the File not found bug.

Pastebin: R9K4JHZN
Great code here. Can I use this for scripts in my OS? Haven't been able to figure file parsing out for a while.
Luca_S #4
Posted 25 October 2017 - 05:30 PM
Tiedied up the loop a bit and also put the execution of the commands after the reading in, so that commands that take a longer time don't keep the FS handle open.
Also this fixes the File not found bug.

Pastebin: R9K4JHZN
Great code here. Can I use this for scripts in my OS? Haven't been able to figure file parsing out for a while.

No problems from my side.
minebuild02 #5
Posted 25 October 2017 - 05:34 PM
Tiedied up the loop a bit and also put the execution of the commands after the reading in, so that commands that take a longer time don't keep the FS handle open.
Also this fixes the File not found bug.

Pastebin: R9K4JHZN
Great code here. Can I use this for scripts in my OS? Haven't been able to figure file parsing out for a while.

No problems from my side.
Thanks. Will put you up in the credits for Tesseract.
Ilikemlp123 #6
Posted 30 October 2017 - 03:08 AM
Tiedied up the loop a bit and also put the execution of the commands after the reading in, so that commands that take a longer time don't keep the FS handle open.
Also this fixes the File not found bug.

Pastebin: R9K4JHZN
Great code here. Can I use this for scripts in my OS? Haven't been able to figure file parsing out for a while.
always. i appreciate people using my programs. i've been quite busy recently so i can't respond immediately