RedPower Forth paster

Discussion in 'Programming' started by sk89q, 11 January 2013.

  1. sk89q

    sk89q Administrator
    Staff Member

    Joined:
    1 December 2011
    Messages:
    2.490
    Likes Received:
    1.504
    This is a simple AutoHotkey script I made to paste Forth programs into the RedPower 2 computers. It requires AutoHotkey, which is unfortunately Windows-only.
    • Automatically strips out comments.
    • Removes indentation and unnecessary spaces.
    • Waits for cues for typing more code.
    • Extremely fast.
    Get AutoHotkey from: http://www.autohotkey.com

    Download the attached file and extract the contents somewhere. Double click the forth_paster.ahk script. To start pasting code:
    1. Copy the code to your clipboard.
    2. Make sure Minecraft is your active window and that you are in a RP2 computer.
    3. Make sure the shell is clear of any typed text.
    4. Hit CTRL-W.
    Possible problems:
    1. The script uses image searching and I only gave the images for the GUI scale I use. If you use a different one, please post the images for it here. (Replace the images that come in the .zip with bigger versions.)
    [h2]Example Usage[/h2]
    If you were to copy the following code:
    Code:
    : SORT ( -- )
    CR
    BEGIN
    OUTID
    \ check input to see whether we need to send
        3 IOXADDR ! ( bus ID is incoming bundled cabling for signaling )
        IOX@ DUP DUP DUP
        1 AND IF
            64 0 SORTPULL DROP ( pull out item )
            2/ 31 AND DUP
            IF
                DUP
                    ." Bus:" .
                    SORTADDR !
                6 U>> 15 AND DUP
                    ." Color:" .
                    SORTCOLOR!
                10 U>> 255 AND DUP
                    ." Amount:" .
                    ." ..."
                    SORTMATCH
            ELSE
                DROP ." Unsorted..."
            THEN
            ." OK" CR
        ELSE
            40 TICKS
            DROP DROP DROP
        THEN
    AGAIN
    ;
    The following would be shown on your screen:
    Code:
    > : SORT
    compile: CR
    compile: BEGIN
    compile: OUTID
    compile: 3 IOXADDR !
    compile: IOX@ DUP DUP DUP
    compile: 1 AND IF
    compile: 64 0 SORTPULL DROP
    compile: 2/ 31 AND DUP
    compile: IF
    compile: DUP
    compile: ." Bus:" .
    compile: SORTADDR !
    compile: 6 U>> 15 AND DUP
    compile: ." Color:" .
    compile: SORTCOLOR!
    compile: 10 U>> 255 AND DUP
    compile: ." Amount:" .
    compile: ." ..."
    compile: SORTMATCH
    compile: ELSE
    compile: DROP ." Unsorted..."
    compile: THEN
    compile: ." OK" CR
    compile: ELSE
    compile: 40 TICKS
    compile: DROP DROP DROP
    compile: THEN
    compile: AGAIN
    compile: ;
     

    Attached Files:

    DoomCommando and Popsicle67 like this.