Hey Guys,
I am still working on my programming language and I have already added classes, but I want a different way to use classes. I was thinking along the lines of my classes being something like this:
Program()
{
code goes here
goto Next
}
Next()
{
jumps to here
}
That is what I have in mind, but I don't know how to do it. I was thinking it would be something like:
dim class as string = "Program"
dim id as integer = indexof("{")
dim id2 as integer = lastindexof("}")
dim code as string = class, id + 1, id2 - id - 1
It would be something like that and then changing classes would be something like:
Begin:
dim class as string = "Program"
dim id as integer = indexof("{")
dim id2 as integer = lastindexof("}")
dim code as string = class, id + 1, id2 - id - 1
Begin:
for each a as string in code.split(system.environment.newline())
some code goes here
some code goes here
some code goes here
if a.startswith("goto ") then
class = a.substring(5)
goto Begin
endif
next
something along the lines of that. I didn't include some things like the textbox1, textbox2. Just saying, TextBox1 is the input and the TextBox2 is the output. So my final code looks something like this:
dim class as string = "Program"
dim id as integer = indexof("{")
dim id2 as integer = lastindexof("}")
dim code as string = textbox1.text
dim source as string = ""
Begin:
for each a as string in code.split(system.environment.newline())
if a.startswith(class) then
source = class, id + 1, id2 - id - 1
for each b as string in source.split(system.environment.newline())
(some code goes here)
(some code goes here)
(some code goes here)
if b.startswith("goto ")
class = a.substring(5)
goto Begin
endif
next
endif
next
sorry if it looks a little confusing but this is what I think the code would look like for classes in my programming langauge. I know that this isn't what it is and I think it has something to do with Regex Methods(I don't know how to use them, so I havn't tried) and can you guys please help me?
[edit]Code blocks added - OriginalGriff[/edit]