Created
May 30, 2020 18:54
-
-
Save jacob-g/2fe9f3f613c8ef7aeff7c8efd0b583e7 to your computer and use it in GitHub Desktop.
ACID programming language - this is something I did in about 2010, just posting for historical value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cs ---------------------------------------------------------------------------- | |
AutoIt Version: 3.3.6.1 | |
Author: jvvg Industries Corporation | |
Script Function: | |
To create a programming interface. | |
Script Title: | |
Advanced Computer Integrated Development | |
Version: | |
Gamma | |
#ce ---------------------------------------------------------------------------- | |
;declare global vars/arrays | |
Global $consoleout, $nerds, $fullcounter, $curcmd, $totalcmd, $cmdarray, $newcounter, $file, $codeentry | |
Global $vars[100] | |
Global $labels[1000] | |
;set iniaial values | |
$consolewin = 0 | |
#include <jvvgFunctions.au3> | |
#include <ListBoxConstants.au3> | |
#NoTrayIcon | |
$file = "./\*:" | |
Func Load ($infile) | |
GUICtrlSetData ($codeentry, FileRead ($infile)) | |
$file = $infile | |
EndFunc | |
Func Save ($as = 0) | |
If $file = "./\*:" Or $as = 1 Then $file = FileSaveDialog ("ACID-Save as", @MyDocumentsDir, "ACID Files (*.acid)|All Files (*.*)") | |
If $file = "" Then | |
$file = "./\*:" | |
Return | |
EndIf | |
$file2 = StringSplit ($file, "\") | |
If Not StringInStr ($file2[$file2[0]], ".") Then $file = $file & ".acid" | |
FileOpen ($file, 2) | |
FileWrite ($file, GUICtrlRead ($codeentry)) | |
FileClose ($file) | |
EndFunc | |
Func Register () | |
RegWrite ("HKCR\.acid\", "", "REG_SZ", "jvvgindustriesacid") | |
RegWrite ("HKCR\jvvgindustriesacid\", "", "REG_SZ", "ACID Programming Code") | |
RegWrite ("HKCR\jvvgindustriesacid\DefaultIconre", "", "REG_SZ", @ScriptFullPath & ",0") | |
RegWrite ("HKCR\jvvgindustriesacid\shell\", "", "REG_SZ", "open") | |
RegWrite ("HKCR\jvvgindustriesacid\shell\open\", "", "REG_SZ", "Open with ACID") | |
RegWrite ("HKCR\jvvgindustriesacid\shell\open\command\", "", "REG_SZ", '"' & @ScriptFullPath & '" "%1"') | |
MsgBox (0, "ACID", "This program is now the default program to run .acid files.", 0, $parent) | |
EndFunc | |
If @Compiled And RegRead ("HKCR\.acid\", "") = "" Then | |
If IsAdmin () Then | |
Else | |
If RegRead ("HKCU\Software\jvvg Industries\ACID", "DisplayStartMsg") = "" Then | |
$doagain = MsgBox (260, "ACID", "To register this program, run it as an administrator." & @CRLF & "Do you want to disable this message?") | |
If $doagain = 6 Then RegWrite ("HKCU\Software\jvvg Industries\ACID", "DisplayStartMsg", "REG_SZ", 0) | |
EndIf | |
EndIf | |
EndIf | |
$parent = GUICreate ("Advanced Computer Integrated Development - Gamma Edition", 1024, 768) | |
$codeentry = GUICtrlCreateEdit ("!Insert Code Here", 5, 55, 1014, 708) | |
$run = GUICtrlCreateButton ("Run", 5, 5) | |
$break = GUICtrlCreateButton ("Break", 40, 5) | |
$fornerds = GUICtrlCreateCheckbox ("Output for nerds?", 100, 7) | |
$savebtn = GUICtrlCreateButton ("Save", 220, 5) | |
$openbtn = GUICtrlCreateButton ("Open", 265, 5) | |
$saveasbtn = GUICtrlCreateButton ("Save As...", 310, 5) | |
If IsAdmin () Then | |
$register = GUICtrlCreateButton ("Register...", 380, 5) | |
Else | |
$register = GUICtrlCreateDummy () | |
EndIf | |
If $cmdline[0] > 0 Then | |
Load ($cmdline[1]) | |
EndIf | |
GUICtrlSetState ($break, $GUI_DISABLE) | |
GUISetState (@SW_SHOW) | |
Do | |
$msg = GUIGetMsg (1) | |
Switch $msg[0] | |
Case $GUI_EVENT_CLOSE | |
Switch $msg[1] | |
Case $parent | |
Exit | |
Case $consolewin | |
GUIDelete ($consolewin) | |
EndSwitch | |
Case $run | |
If GUICtrlRead ($fornerds) = $GUI_CHECKED Then | |
$nerds = 1 | |
Else | |
$nerds = 0 | |
EndIf | |
$output = RunScript () | |
GUICtrlSetState ($break, $GUI_DISABLE) | |
GUICtrlSetState ($run, $GUI_ENABLE) | |
SoundPlay ("") | |
If $output = 1 Then | |
Write ("<--Script Exit at " & @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR & "-->") | |
Else | |
Write ("WARNING!>Process failed to respond! Terminating...") | |
Write ("<--Script Break at " & @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR & "-->") | |
EndIf | |
Case $register | |
Register () | |
Case $savebtn | |
Save () | |
Case $saveasbtn | |
Save (1) | |
Case $openbtn | |
$infile = FileSaveDialog ("ACID-Open what file?", @MyDocumentsDir, "ACID Files (*.acid)|All Files (*.*)") | |
If $infile <> "" Then load ($infile) | |
EndSwitch | |
Until 0 | |
Func RunScript () | |
;prepare to run | |
For $i = 0 To 999 | |
$labels[$i] = -1 | |
Next | |
;nullify variables | |
For $i = 0 To 9 | |
$vars[$i] = 0 | |
Next | |
;get labels | |
$cmd = GUICtrlRead ($codeentry) & @CR | |
$cmd = @CRLF & $cmd | |
$cmdarray = StringSplit ($cmd, @CR) | |
$crlf = 0 | |
For $i = 1 To $cmdarray[0] | |
$cmdarray[$i] = StringTrimLeft ($cmdarray[$i], 1) | |
If StringLeft($cmdarray[$i], 1) = ":" Then | |
$labels[StringTrimLeft($cmdarray[$i], 1)] = $i | |
EndIf | |
Next | |
GUICtrlSetState ($run, $GUI_DISABLE) | |
GUICtrlSetState ($break, $GUI_ENABLE) | |
$fullcounter = 0 | |
If $consolewin <> 0 Then GUIDelete ($consolewin) | |
If $nerds Then | |
$consolewin = GUICreate ("ACID Output For Nerds", 500, 500, -1, -1, -1, -1, $parent) | |
Else | |
$consolewin = GUICreate ("ACID Output", 500, 500, -1, -1, -1, -1, $parent) | |
EndIf | |
$consoleout = GUICtrlCreateList ("", 5, 5, 490, 490, $LBS_NOSEL + $WS_VSCROLL) | |
GUISetState (@SW_SHOW) | |
Write ("<--Script Start at " & @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR & "-->") | |
;get data | |
$totalcmd = GUICtrlRead ($codeentry) | |
$curcmd = GUICtrlRead ($codeentry) | |
If StringRight ($curcmd, 1) <> @CRLF Then $curcmd = $curcmd & @CRLF | |
$fullcounter = 0 | |
Do | |
$fullcounter = $fullcounter + 1 | |
$newcounter = RunCode ($cmdarray[$fullcounter]) | |
If $newcounter <> .5 Then $fullcounter = $newcounter | |
Until $fullcounter = $cmdarray[0] | |
Return 1 | |
EndFunc | |
Func RunCode ($cmd) | |
$success = 1 | |
For $i = 0 To 99 | |
If $vars[$i] <> "" Then | |
$cmd = StringReplace ($cmd, "$" & $i, $vars[$i]) | |
EndIf | |
Next | |
If $nerds Then Write ($fullcounter & ">Command>" & $cmd) | |
If StringLeft ($cmd, 1) <> "!" And StringLeft ($cmd, 1) <> "#" And StringLeft ($cmd, 1) <> ":" Then | |
Select | |
Case StringLeft ($cmd, 8) = "declare " | |
$i = StringRight (StringLeft ($cmd, 10), 2) | |
$vars[$i] = StringTrimLeft ($cmd, 11) | |
Case StringLeft ($cmd, 6) = "write " | |
;write to the console | |
If $nerds Then | |
Write ($fullcounter & ">Output>" & StringTrimLeft ($cmd, 6)) | |
Else | |
Write (StringTrimLeft ($cmd, 6)) | |
EndIf | |
Case StringLeft ($cmd, 7) = "msgbox " | |
;message box | |
$params = StringSplit (StringTrimLeft ($cmd, 7), ";;", 1) | |
If $params[0] > 1 Then | |
MsgBox (0, $params[1], $params[2], 0, $parent) | |
Else | |
Write ("Message Box: Command Error-Not enough parameters!!!") | |
EndIf | |
Case StringLeft ($cmd, 5) = "kill " | |
;kill something | |
Select | |
Case StringLeft ($cmd, 13) = "kill process " | |
;kill process | |
ProcessClose (StringTrimLeft ($cmd, 13)) | |
Case StringLeft ($cmd, 10) = "kill file " | |
;delete file | |
FileDelete ($cmd) | |
Case Else | |
ParamNotRecognized (StringTrimLeft ($cmd, 5), "kill") | |
EndSelect | |
Case StringLeft ($cmd, 5) = "play " | |
Select | |
Case StringLeft ($cmd, 11) = "play sound " | |
;play sound | |
If FileExists (StringTrimLeft ($cmd, 11)) Then | |
SoundPlay (StringTrimLeft ($cmd, 11)) | |
Else | |
If $nerds Then | |
Write ($fullcounter & ">Error>File does not exist") | |
Else | |
Write ("File '" & StringTrimLeft ($cmd, 11) & "' does not exist.") | |
EndIf | |
EndIf | |
Case StringLeft ($cmd, 12) = "play soundW " | |
;play sound | |
If FileExists (StringTrimLeft ($cmd, 12)) Then | |
SoundPlay (StringTrimLeft ($cmd, 12), 1) | |
Else | |
If $nerds Then | |
Write ($fullcounter & ">Error>File does not exist") | |
Else | |
Write ("File '" & StringTrimLeft ($cmd, 11) & "' does not exist.") | |
EndIf | |
EndIf | |
Case StringLeft ($cmd, 15) = "play sound:stop" | |
SoundPlay ("") | |
Case Else | |
ParamNotRecognized (StringTrimLeft ($cmd, 5), "play") | |
EndSelect | |
Case StringLeft ($cmd, 6) = "delay " | |
For $counter = 1 To StringTrimLeft ($cmd, 6) / 10 | |
If CheckForExit () Then Return 0 | |
Sleep (10) | |
Next | |
Case StringLeft ($cmd, 6) = "input " | |
$v = StringRight (StringLeft ($cmd, 8), 2) | |
$prompt = StringTrimLeft ($cmd, 9) | |
$output = InputBox ("ACID Input Request", $prompt, "", "", 250, 190, Default, Default, 0, $parent) | |
If $output <> "" Then | |
$vars[$v] = $output | |
Else | |
$vars[$v] = "error" | |
EndIf | |
If $nerds And $output <> "" Then Write ($fullcounter & ">Result>" & $output) | |
If $nerds And $output = "" Then Write ($fullcounter & ">Error>User cancelled.") | |
Case StringLeft ($cmd, 3) = "if " | |
$i = 0 | |
Do | |
$i = $i + 1 | |
Until StringInStr (StringLeft ($cmd, $i), "then ") | |
$cond = StringLeft ($cmd, $i) | |
$com = StringTrimLeft ($cmd, $i) | |
$cond = StringReplace ($cond, " ", "") | |
$cond = StringReplace ($cond, "then", " then ") | |
$cond = StringReplace ($cond, "if", "if ") | |
$cmd = $cond & $com | |
$str2test = "" | |
$i = 0 | |
Do | |
$i = $i + 1 | |
$str2tst = StringLeft ($cmd, $i) | |
Until StringInStr ($str2tst, "=") | |
$v1 = StringTrimLeft (StringTrimRight ($str2tst, 1), 3) | |
$str2tst = StringTrimLeft ($cmd, $i) | |
$i2 = $i | |
Do | |
$i2 = $i2 + 1 | |
$str2tst = StringLeft ($cmd, $i2) | |
Until StringInStr ($str2tst, " then ") | |
$v2 = StringTrimLeft (StringTrimRight ($str2tst, 6), $i) | |
If $v1 = $v2 Then | |
RunCode (StringTrimLeft ($cmd, $i2) & " ") | |
EndIf | |
Case StringLeft ($cmd, 4) = "*if " | |
$i = 0 | |
Do | |
$i = $i + 1 | |
Until StringInStr (StringLeft ($cmd, $i), "then ") | |
$cond = StringLeft ($cmd, $i) | |
$com = StringTrimLeft ($cmd, $i) | |
$cond = StringReplace ($cond, " ", "") | |
$cond = StringReplace ($cond, "then", " then ") | |
$cond = StringReplace ($cond, "if", "if ") | |
$cmd = $cond & $com | |
$str2test = "" | |
$i = 0 | |
Do | |
$i = $i + 1 | |
$str2tst = StringLeft ($cmd, $i) | |
Until StringInStr ($str2tst, "=") | |
$v1 = StringTrimLeft (StringTrimRight ($str2tst, 1), 4) | |
$str2tst = StringTrimLeft ($cmd, $i) | |
$i2 = $i | |
Do | |
$i2 = $i2 + 1 | |
$str2tst = StringLeft ($cmd, $i2) | |
Until StringInStr ($str2tst, " then ") | |
$v2 = StringTrimLeft (StringTrimRight ($str2tst, 6), $i) | |
If $v1 <> $v2 Then | |
RunCode (StringTrimLeft ($cmd, $i2) & " ") | |
EndIf | |
Case StringLeft ($cmd, 5) = "goto " | |
$label2use = StringTrimRight (StringTrimLeft ($cmd, 5), 0) | |
If $labels[$label2use] = -1 Then | |
Write ("Error: " & $label2use & " is an undeclared label.") | |
ConsoleWrite ($label2use & @CRLF) | |
Else | |
$fullcounter = $labels[$label2use] | |
EndIf | |
Case StringLeft ($cmd, 7) = "input* " | |
$v = StringRight (StringLeft ($cmd, 9), 2) | |
$prompt = StringTrimLeft ($cmd, 10) | |
$output = InputBox ("ACID Input Request", $prompt, "", "*", 250, 190, Default, Default, 0, $parent) | |
If $output <> "" Then | |
$vars[$v] = $output | |
Else | |
$vars[$v] = "error" | |
EndIf | |
If $nerds And $output <> "" Then Write ($fullcounter & ">Result>" & $output) | |
If $nerds And $output = "" Then Write ($fullcounter & ">Error>User cancelled.") | |
Case StringLeft ($cmd, 6) = "yesno " | |
$v = StringRight (StringLeft ($cmd, 8), 2) | |
$prompt = StringTrimLeft ($cmd, 9) | |
$output = MsgBox (4, "ACID", $prompt, 0, $parent) | |
If $output = 6 Then $output = 1 | |
If $output = 7 Then $output = 0 | |
$vars[$v] = $output | |
If $nerds And $output <> "" Then Write ($fullcounter & ">Result>" & $output) | |
Case StringLeft ($cmd, 5) = "math " | |
If Not StringInStr ($cmd, ":", 2, 2) Then | |
Write ($fullcounter & ">" & "Badly formatted.") | |
$success = 0 | |
Return .5 | |
EndIf | |
;get return variable | |
$v = StringRight (StringLeft ($cmd, 7), 2) | |
If StringRight (StringLeft ($cmd, 7), 1) = "=" Then | |
;get value 1 | |
$cmd = StringTrimLeft ($cmd, 7) | |
$counter = 0 | |
Do | |
$counter = $counter + 1 | |
Until StringInStr (StringLeft ($cmd, $counter), ":") | |
$val1 = StringTrimRight (StringLeft ($cmd, $counter), 1) | |
;get value 2 | |
$cmd = StringTrimLeft ($cmd, $counter) | |
$counter = 0 | |
Do | |
$counter = $counter + 1 | |
Until StringInStr (StringLeft ($cmd, $counter), ":") | |
$val2 = StringTrimRight (StringLeft ($cmd, $counter), 1) | |
Switch StringRight ($cmd, 1) | |
Case "+" | |
$vars[$v] = $val1 + $val2 | |
Case "-" | |
$vars[$v] = $val1 - $val2 | |
Case "*" | |
$vars[$v] = $val1 * $val2 | |
Case "/" | |
$vars[$v] = $val1 / $val2 | |
Case "^" | |
$vars[$v] = $val1 ^ $val2 | |
Case "&" | |
$vars[$v] = $val1 & $val2 | |
EndSwitch | |
Else | |
Write ($fullcounter & ": Math Error: Invalid sign!") | |
EndIf | |
Case StringLeft ($cmd, 8) = "savedlg " | |
$v = StringRight (StringLeft ($cmd, 10), 2) | |
$params = StringSplit (StringTrimLeft ($cmd, 11), ";;", 1) | |
If $params[0] > 2 Then | |
$vars[$v] = FileSaveDialog ($params[1], $params[2], $params[3]) | |
Else | |
Write ("Save Dialog-Command Error: Not enough parameters!!!") | |
EndIf | |
Case StringLeft ($cmd, 8) = "opendlg " | |
$v = StringRight (StringLeft ($cmd, 10), 2) | |
$params = StringSplit (StringTrimLeft ($cmd, 10), ";;", 1) | |
If $params[0] > 2 Then | |
$vars[$v] = FileOpenDialog ($params[1], $params[2], $params[3], 1) | |
Else | |
Write ("Save Dialog-Command Error: Not enough parameters!!!") | |
EndIf | |
Case StringLeft ($cmd, 7) = "readln " | |
$v = StringRight (StringLeft ($cmd, 9), 2) | |
$params = StringSplit (StringTrimLeft ($cmd, 9), ";;", 1) | |
If $params[0] > 1 Then | |
$vars[$v] = FileReadLine ($params[1], $params[2]) | |
Else | |
Write ("File Read Line-Command Error: Not enough parameters!!!") | |
EndIf | |
Case StringLeft ($cmd, 8) = "readall " | |
$v = StringRight (StringLeft ($cmd, 10), 2) | |
$vars[$v] = FileRead (StringTrimLeft ($cmd, 10)) | |
Case $cmd = "" Or $cmd = @CRLF | |
Case Else | |
$success = 0 | |
;command not recognized | |
If $nerds Then | |
Write ($fullcounter & ">Error>Not recognized.") | |
Else | |
Write ("Command '" & $cmd & "' not recognized.") | |
EndIf | |
EndSelect | |
EndIf | |
If $success And $nerds Then Write ($fullcounter & ">Return>OK") | |
Return .5 | |
EndFunc | |
Func Write ($text) | |
GUICtrlSetData ($consoleout, $text) | |
EndFunc | |
Func ParamNotRecognized ($param, $command) | |
Write ("Parameter '" & $param & "' for command '" & $command & "' not recognized.") | |
EndFunc | |
Func CheckForExit () | |
If GUIGetMsg () = $break Then | |
Return 1 | |
Else | |
Return 0 | |
EndIf | |
EndFunc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment