Jump to content




LSC (Latch) - A Lua based batch system


5 replies to this topic

#1 Ilikemlp123

  • Members
  • 12 posts

Posted 13 October 2017 - 12: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):
  • type edit, and choose a filename. press enter
  • list the programs and their args in sequential order.
  • press ctrl, then press save
  • 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

View PostLuca_S, on 21 October 2017 - 06:00 PM, said:

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 by Ilikemlp123, 15 November 2017 - 07:44 PM.


#2 Luca_S

  • Members
  • 319 posts
  • LocationGermany

Posted 21 October 2017 - 06: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 by Luca_S, 21 October 2017 - 06:00 PM.


#3 minebuild02

  • Members
  • 93 posts

Posted 25 October 2017 - 03:10 PM

View PostLuca_S, on 21 October 2017 - 06:00 PM, said:

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.

#4 Luca_S

  • Members
  • 319 posts
  • LocationGermany

Posted 25 October 2017 - 04:30 PM

View Postminebuild02, on 25 October 2017 - 03:10 PM, said:

View PostLuca_S, on 21 October 2017 - 06:00 PM, said:

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.

#5 minebuild02

  • Members
  • 93 posts

Posted 25 October 2017 - 04:34 PM

View PostLuca_S, on 25 October 2017 - 04:30 PM, said:

View Postminebuild02, on 25 October 2017 - 03:10 PM, said:

View PostLuca_S, on 21 October 2017 - 06:00 PM, said:

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.

#6 Ilikemlp123

  • Members
  • 12 posts

Posted 30 October 2017 - 03:08 AM

View Postminebuild02, on 25 October 2017 - 03:10 PM, said:

View PostLuca_S, on 21 October 2017 - 06:00 PM, said:

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users