This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-04-17 07:50:03

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

How to program a programming language within Scratch

This topic is a guide to programming programming languages. I have made QuickSilver. Another example is Skip by ScratchReallyROCKS. I will use the QuickSilver platform for this guide. So, I recommend downloading it and learning it.

Instead of telling you exactly how to make one, I'm going to give you ideas for how to solve problems like variables, repeats, etc. So, let's get started!

Chapter 1: How it all works
The biggest problem for most programming language programmers is how to get started. The easiest way is to think of a program as a list. You also need a variable called 'Line'. The basic coding then becomes:

Code:

Set Line to 1
Repeat until Line = Length of List
    Change Line by 1
    If item Line of List = {command}
        {action}
    If item Line of List = {other command}
        {other action}
    etc.

There are a few extra things (like arguments, flow control, and terminators) but we'll worry about those later.

Chapter 2: Arguments
An argument is basically an input. The (5)+(10) block takes two arguments, 5 and 10 in this case.
The best way to deal with arguments is to have each argument in a new line:

Code:

{command}
{argument 1}
{argument 2}

Now, arguments can be represented by the simple coding

Code:

(Item ((Line)+(1)) of (List))

Make sure you put in a [change (Line) by {number of arguments}] at the end.
Here's an example of how this could be used:

Code:

Set Line to 1
Repeat until Line = Length of List
    Change Line by 1
    If item Line of List = 'PRINT'
        Say (item(Line+1) of (List))
        Change Line by 1

Chapter 3: Variables
The best way to battle variables is with a list called 'variables'. Each item stands for a variable. So, you can add, edit, and use variables. But you can't name them. To name them, you need the list 'variable names'. 'Variable names' contains all the variables' names (like variables contains the values). Now, the code is

Code:

set n to 1
repeat until item n of var. names = {variable name here}
   change n by 1

item (n) of (variables) is the value of the desired variable

Chapter 4: Flow control
In Scratch, flow control is the orange control blocks. Here, the best way to use flow control is with LBL and GOTO/JMP-like commands. Here's how it works:

Code:

LABEL
loop
Say
Hi!
JMP
loop

Here, LABEL labels that line as 'loop', and JMP tells the script to jump to that line. So, the program will say Hi!, then jump back to 'llop', and say Hi! again and so on. To code this, you can use a similar structure as the variables: a list called LABELS, and one called LABEL NAMES. The only differences are that you put the line number instead of the variable and you add a

Code:

set Line to {input line # here}

at the end.

Chapter 5: Compilation [saving programs]
coming soon

Last edited by Hardmath123 (2011-04-18 12:17:03)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#2 2011-04-17 16:54:10

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: How to program a programming language within Scratch

Nice. I have made a programming language, although it doesn't really work as one. Post some more! This is great!  big_smile

Offline

 

#3 2011-04-17 17:11:52

thebuilderdd
Scratcher
Registered: 2008-01-26
Posts: 1000+

Re: How to program a programming language within Scratch

Do we create a list, also?

Offline

 

#4 2011-04-17 18:27:46

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: How to program a programming language within Scratch

Cool! I'll probably use this code. Maybe this should be stickied.  smile


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#5 2011-04-18 03:27:15

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: How to program a programming language within Scratch

scratcher7_13 wrote:

Cool! I'll probably use this code. Maybe this should be stickied.  smile

Thanks!


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6 2011-04-18 03:36:06

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: How to program a programming language within Scratch

Seems like a really good guide!  However, some of the things that my new programming language 'Cobra'  is going to have a saving and opening system!  I know how to make one, but you might like to show others  wink


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#7 2011-04-18 06:28:49

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: How to program a programming language within Scratch

ssss wrote:

Seems like a really good guide!  However, some of the things that my new programming language 'Cobra'  is going to have a saving and opening system!  I know how to make one, but you might like to show others  wink

I'll add it. Later, though—I need to do flow control.
PS: Thanks for advertising Xenon!


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#8 2011-04-18 06:40:03

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: How to program a programming language within Scratch

Hardmath123 wrote:

ssss wrote:

Seems like a really good guide!  However, some of the things that my new programming language 'Cobra'  is going to have a saving and opening system!  I know how to make one, but you might like to show others  wink

I'll add it. Later, though—I need to do flow control.
PS: Thanks for advertising Xenon!

Your welcome  wink   Although your time is almost up -_-  I am making a software company -_-

You could ask for another week or 2 though  wink


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#9 2011-04-18 10:58:03

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: How to program a programming language within Scratch

Great guide. A good way to do flow control is to use a stack, but that is really advanced.


/* No comment */

Offline

 

#10 2011-04-19 23:21:23

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: How to program a programming language within Scratch

Thanks!


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#11 2011-04-20 07:52:40

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: How to program a programming language within Scratch

Hardmath123 wrote:

Thanks!

Cool!  You are going to add Saving next!

Good work mate!


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#12 2012-06-08 17:00:59

XComputers
Scratcher
Registered: 2011-06-30
Posts: 83

Re: How to program a programming language within Scratch

There is one fatal flaw: unless you don't want the first line to be read, you have to change 'set line to 1' to 'set line to 0'


http://i49.tinypic.com/8vruv5.jpg Go here to learn more or to help develop Apputunaria. Check my signature later to see if X Programming has a forum yet. Learning AI

Offline

 

#13 2012-06-08 17:03:13

XComputers
Scratcher
Registered: 2011-06-30
Posts: 83

Re: How to program a programming language within Scratch

TheSuccessor wrote:

Great guide. A good way to do flow control is to use a stack, but that is really advanced.

What is a stack? Is that when you take data and compile it to one big line using symbols to seperate the items?

Last edited by XComputers (2012-06-08 17:03:26)


http://i49.tinypic.com/8vruv5.jpg Go here to learn more or to help develop Apputunaria. Check my signature later to see if X Programming has a forum yet. Learning AI

Offline

 

#14 2012-06-08 23:02:22

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: How to program a programming language within Scratch

XComputers wrote:

There is one fatal flaw: unless you don't want the first line to be read, you have to change 'set line to 1' to 'set line to 0'

I use the first line for a comment.  wink


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#15 2012-06-08 23:03:25

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: How to program a programming language within Scratch

XComputers wrote:

TheSuccessor wrote:

Great guide. A good way to do flow control is to use a stack, but that is really advanced.

What is a stack? Is that when you take data and compile it to one big line using symbols to seperate the items?

Stacks


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#16 2012-06-08 23:24:59

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: How to program a programming language within Scratch

I think I'll try this tomorrow. Well, not this exactly, but use it as a base😡👉


........................................................................................................................................................................................................................................

Offline

 

#17 2012-06-09 08:17:45

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: How to program a programming language within Scratch

I'm making a scheme interpreter in scratch.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#18 2012-06-09 08:30:08

funelephant
Scratcher
Registered: 2010-07-02
Posts: 1000+

Re: How to program a programming language within Scratch

I might try this! I tried to make Scratch in Scratch. I made 2 blocks, then it sorta, stopped. I might come back to it later.


nicki begs to differ
http://24.media.tumblr.com/ab0e6e8fd347c5e39c2821bcab9d16e6/tumblr_mgu35sui1L1rfb7aqo2_500.gif

Offline

 

#19 2012-06-09 08:35:06

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: How to program a programming language within Scratch

joefarebrother wrote:

I'm making a scheme interpreter in scratch.

Hey, that's what I was doing recently... now I'm curious to see what you make.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#20 2012-06-09 13:54:45

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: How to program a programming language within Scratch

Hardmath123 wrote:

joefarebrother wrote:

I'm making a scheme interpreter in scratch.

Hey, that's what I was doing recently... now I'm curious to see what you make.  smile

Did you ever finish it? I didn't know, so it wasn't copying.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#21 2012-06-09 15:51:34

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: How to program a programming language within Scratch

PHPoison made by me and ssss it suppors same-lin arguments


http://i.imgur.com/1QqnHxQ.png

Offline

 

#22 2012-06-09 22:19:53

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: How to program a programming language within Scratch

joefarebrother wrote:

Hardmath123 wrote:

joefarebrother wrote:

I'm making a scheme interpreter in scratch.

Hey, that's what I was doing recently... now I'm curious to see what you make.  smile

Did you ever finish it? I didn't know, so it wasn't copying.

I wasn't accusing you—I've only mentioned it to bharvey on the BYOB discussion thread. I just finished a JS implementation (which is AWESOME  big_smile ) and now I'm porting it to Scratch with some changes.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#23 2012-06-10 04:00:17

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: How to program a programming language within Scratch

just give me credit on part 5  tongue
faster normally than yours on turbo xD

Offline

 

Board footer