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

[NEW] subpart - create multi-script programs which can be used standalone! [v1.1]

Started by billysback, 05 October 2012 - 08:49 PM
billysback #1
Posted 05 October 2012 - 10:49 PM
SubPart:
is a program which lets you write sub-programs (or parts) for your programs so that they can be more organised!

how to use it:
Spoilertype in 'subpart' in your computer
it will as you to type write/compile/decompile/delete/cancel
*write = start writing your program/part
*compile = compile your program
*decompile = decompile your program
*delete = delete your program
*convert = converts a normal program in to a sub-program for another program!
*cancel = cancel using subpart

then follow the instructions, you can edit the main program using the main editor, or something else like N++, or you can use the sub-program editor by not entering anything in the part section, the sub-program editor is pretty simple to use and will explain it's self to you when you start using it (at the top), the commands are:
##save = save the sub-program (or normal program)
##reset = reset the last saved place (not really working very well)
##exit = exit the editor
##undo = undo the last line
##up = move the cursor up to the line above, to change that line
##down = move the cursor down to the line below, to change that line
##input = input a blank line in to the cursor position

these commands are used by typing them in as input, they are not put in to the program file.


when the program is compiled it is run like a normal program, just run the program.

to use any of the functions from other sub-functions use subfunctionname_function(), to use functions in the main program just do function()

so something like:
msg_message("Hello world!")
to call then function "message" in the sub-program "msg"


NOTE: EXTREMLY IMPORTANT; in order for the compilation to work you must have a line in your code which has ONLY –input parts on it, this is must be above any code which uses the functions inside other parts, usually at the top unless you have real reason not to place it there!

(plus parts and programs should be able to share variables as well, in the same way as functions)

This was created after I realized that my programs were getting way too messy,
and thought everyone else might find it useful as well!

Paste
Spoilerhttp://pastebin.com/eqYC1ehN

To Do:
-nothing yet!

Updates:
Spoiler*Released v1.0
*Added convert, improved and fixed compiler/decompiler (v1.1)

Hope you like it, please tell me what you want, this was a bit rushed (it's late), sorry!

Download:
Spoilerv1.1: [attachment=527:subpart.zip]

NOTE: once compile 100% of the code is in the program file and you can export it / use it standalone, without subpart or any other files. This means that you can create a program using subpart, compile it then upload nothing but that program file, however the program file will look strange.
billysback #2
Posted 06 October 2012 - 10:16 AM
Updated to v1.1:
*Added convert, improved and fixed compiler/decompiler (v1.1)