What is an interpreted scripting language?
It's a language that allows you to perform instructions on a machine, though it does not compile. It also translates down to a different language, and most commonly uses one-line commands (and could miss various typical characteristics of a true programming language).
I just made up a small project that works with making your own scripting language, so it will not compile (unless you make it compile) and will translate down to VB. An example script that will run with the code I provide could be something like:
I won't be explaining each part individually, so instead I commented my source. Please don't steal my work, because I'll come at you with my fangs out
This is NOT a beginner's project. Best suited for intermediates and advanced programmers. Examples of current programs that use this method for its scripting are both my scriptable autotalker and autoclicker in the verified programs section.
It's a language that allows you to perform instructions on a machine, though it does not compile. It also translates down to a different language, and most commonly uses one-line commands (and could miss various typical characteristics of a true programming language).
I just made up a small project that works with making your own scripting language, so it will not compile (unless you make it compile) and will translate down to VB. An example script that will run with the code I provide could be something like:
Code:
=start=
alert("YOOO");
alert("YOHOHOHOHOHO");
goTo(=nextMethod=);
=nextMethod=
alert("This is part of the second method");
gotoLine(3);
I won't be explaining each part individually, so instead I commented my source. Please don't steal my work, because I'll come at you with my fangs out
This is NOT a beginner's project. Best suited for intermediates and advanced programmers. Examples of current programs that use this method for its scripting are both my scriptable autotalker and autoclicker in the verified programs section.
Code:
Public Class Form1
' Run button event
Private Sub cmdRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRun.Click
' This array will store each line of code
' You can merge the following two lines of code into one, it just depends on preference. I like to do it like this.
Dim arr() As String = Nothing
' Split the code with the vbLf delimiter (line-feed)
arr = Split(txtScript.Text, vbLf)
' Make a variable for the # of lines in the script
Dim lines As Integer = arr.Length
' Run through loop for every line
For i As Integer = 0 To arr.Length - 1
' Add extra delimiter onto each line, this is for parsing
arr(i) = arr(i) & ");"
' If the line starts with "alert" then we have the alert command
If arr(i).StartsWith("alert") Then
' Get the text the user wants to alert with GetBetween
Dim str As String = GetBetween(arr(i), "alert(""", """);")
' Make alert
MsgBox(str)
End If
' If line starts with goTo (case sensitive) it is the goto command
If arr(i).StartsWith("goTo") Then
' Get the method name to which the user wants to go to
Dim str As String = GetBetween(arr(i), "goTo(=", "=);")
' Variable for the line where the method is
Dim gotoline As Integer
' Go through script again to find the method
For j As Integer = 0 To arr.Length - 1
If arr(j).StartsWith("=" & str) Then
' The line # is the counter +1 because j starts at 0 and the line numbers start at 1
gotoline = j + 1
End If
Next
' Change i so that we start the loop at the method in the goTo command
i = gotoline - 1
End If
' If line starts with gotoLine (case sensitive) then its the gotoLine command
If arr(i).StartsWith("gotoLine") Then
' Get line # to go to
Dim str As String = GetBetween(arr(i), "gotoLine(", ");")
' Int variable to store # in
Dim lInt As Integer
' If it isn't numeric...
If IsNumeric(str) = False Then
' This should throw some kind of exception
lInt = 0
' If it is numeric, then store it as a conversion
Else
lInt = CInt(str)
End If
' Change the counter so that we go to the specific line the user wants to go to
i = lInt - 2
End If
Next
End Sub
' GetBetween function, gets between strings start and finish in string source
Private Function GetBetween(ByVal Source As String, ByVal Start As String, ByVal Finish As String) As String
' Get the starting index in the source string
Dim index As Integer = InStr(Source, Start) + (Start.Length - 1)
' Get the ending index in the source string
Dim fIndex As Integer = InStr(Source, Finish) - 1
' Determine the length of the string we got between Start and Finish
Dim len As Integer = fIndex - index
' Return that string starting at the start index, and going for the length of characters it is
Return Source.Substring(index, len)
End Function
End Class

