crashdemons Posted March 8, 2010 Posted March 8, 2010 (edited) After some some looks at "Boat" and "BeFunge" someone challenged me to make a simplistic 2D language in AutoIt that can handle console input/output.So, here we are - a language that can be typed out like a circuit, can perform operations on a buffer, and mess with the console.This was all originally going to be written in C++, but it was written for AutoIt 3.3.2.0.I warn you, this "language" is utterly useless useful.Programs might be convertable from Brainfuck and this language may be Turing-complete! See the Comment #17!Like Befunge, the language uses single-character operators in the direction the program is flowing in.Like Boat and Befunge, the code uses ><^v as directional operators.Unlike either, certain operators turn the flow 90-degrees clockwise under certain conditions. (for switches and error handling)I have attached a ZIP containing: - the interpreter (script), - a visual debug program (shows flow visually as processed, processed operators and a portion of the buffer), - a documentation file that contains all operators, descriptions, and examples.ab.zipHow to use this:1. Compile AutoBoat.au3 as a CUI "AutoBoat.exe" - (Or Build with AutoIt3Wrapper, the Change2CUI entry is already there.)2. Write or save an AutoBoat script in a file. (ANSI text only)3. Run AutoBoat.exe scriptFilePath on a command-line to execute the script.4. Watch the output (if any is done in the script)Note: It may be easiest to open a command prompt, drag in AutoBoat.exe, hit space, and drag in the script file. That should give the correct command-line on newer OS'.Warning: The debug program is made for SMALL programs and does not check length/height before extending the GUI...Since this is so useless I consider this more of a joke than an attempt at anything, so feel free to make whatever comments you feel are appropriate. Edited July 27, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
trancexx Posted March 8, 2010 Posted March 8, 2010 You are right. It's useless. Nevertheless it's useless. Nice. ♡♡♡ . eMyvnE
corgano Posted March 8, 2010 Posted March 8, 2010 Thats pretty nice. Might find a use for it.... (maby a game?) 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
IchBistTod Posted March 29, 2010 Posted March 29, 2010 found something intresting >=+86#==V | >=======V | | # + + + + + + # | | ^=#+++==< runs fine but >=+86#==V | >=======V | | . + + + + + + . | | ^=.+++==< hangs, LOL Its fun to play with. [center][/center][center]=][u][/u][/center][center][/center]
IchBistTod Posted March 29, 2010 Posted March 29, 2010 >=====V >=====V ^ | >=="LOL"==V ^ | | " | | | | | L | | | | " O | | | | L L | | | | O " | | | | L | ^ | | | >=V " >======>==\< | | >==="LOL"/<| | V >=^ V | | | | | | | ^===="LOL"======<=="LOL"==< ^====="LOL"====< | ^==================< =] lol [center][/center][center]=][u][/u][/center][center][/center]
AlmarM Posted March 29, 2010 Posted March 29, 2010 I think it's me but, how do I run/use it? Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
NoComment Posted March 29, 2010 Posted March 29, 2010 I think it's me but, how do I run/use it? Ok, I figured out how to use this: 1. Right click the AutoBoat.au3 file. 2. Choose the "Compile with Options" option. 3. Ensure the "Create CUI instead of GUI.exe" option is checked. 4. Compile the script. 5. Copy and paste the compile script into your C:\WINDOWS\ directory (this is to make it easier on you). 6. Go to command prompt 7. Type autoboat.exe "[Directory]" PS: It is easier to move the test.txt file to the C:\ directory and type in autoboat.exe C:\test.txt.
IchBistTod Posted March 29, 2010 Posted March 29, 2010 And its not useless it kept me up for 2 hours having fun fuckin with it. LOL. [center][/center][center]=][u][/u][/center][center][/center]
WeMartiansAreFriendly Posted March 30, 2010 Posted March 30, 2010 Thats pretty nice. Might find a use for it.... (maby a game?)That's exactly what I was thinking, I seen plenty of games that use something like this for levels. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
crashdemons Posted March 30, 2010 Author Posted March 30, 2010 (edited) Arrghh I didn't get a notification from the board of any replies - low and behold, Replies!---About running,You can use AutoBoat.exe "path-to-script" to run a script (a script being in the form shown in the above screenshot).All programs script in this language are meant to be CUI programs.Frankly I just open a Command Prompt window, drag-drop in AutoBoat.exe (pasts the path to the file inside quotes), hit space, then drag-drop in the script file. Hit enter.The script determines what is output - there are descriptions for some of my examples in the TXT. The script MUST start at the upper-left character in the file and it must NOT be a unicode/utf format text file (only regular ANSI).@IchBistTod - neither of your scripts hang for me, not that I understood what you were trying to do besides print out all characters after 0x30 ("0") in increments of 3. Could be a difference between our AutoIt version, or even our OS; but it will either depend on how the au3 script is ran - or how the characters being printed are handled.(Note: certain characters printed from your script equate to one that makes the internal speaker beep on my OS.)Also, did you want your 3rd example to do anything besides fill the "buffer" with LOLOLOL and loop? @All - it might be useful for some minor input/output programs - maybe even a text-based adventure! (doubt it) - but it has some limitations to work around or fix. Edited March 30, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
IchBistTod Posted March 31, 2010 Posted March 31, 2010 Also, did you want your 3rd example to do anything besides fill the "buffer" with LOLOLOL and loop? If you notice the structure of the code (being a giant LOL itself)No sir, it was to serve no purpose but to endlessly buffer LOL.*makes it compiled*2 Months Later:*Normal user views forum, AV Goes off, "AutoItBoat.Gen.LOL Detected!".LOL, epics LOL Virus. Not that I would ever do that.I will takeit on to actually make a usefull application out of this.Maybe you could make it compile? Using EOF Data with INI write to write the file as an ecrypted string to the end of the exe?that would be cool.Maybe still useless, but cool xD [center][/center][center]=][u][/u][/center][center][/center]
crashdemons Posted March 31, 2010 Author Posted March 31, 2010 (edited) NOTE: code box spacing fixed EDIT: Fixed the bottom missing off my edited LOL. (guess that makes it a LMAO?) @IchBistTod I didn't really supply a way to create an AutoIt program with an AutoBoat script compiled into it. You can strip out the first part where "ProcCmdLineFile()" is called or Write a script that defines "__AutoBoatDebug__" as nonzero (keeps from processing the command-line) then Include AutoBoat.au3; the variable was originally added just to let the Debug program take-over the processing. Having done one of the above, you can use one of the following to write a script that will compile to a single file and still run the AutoBoat script: A. set a variable to a string containing your script, and call Proc($variable) B. FileInstall your script and Proc(FileRead(filename)) or whatever Btw this should be processed the same way as your earlier LOL example: >=====V >=====V ^ | >=="LOL"==V ^ | | " | | | | | L | .---. | | | " O | | | | | | L L | | | | | | O " | | | | | | L | ^ | | | | | >=V " >======>==\< | | | | >==="LOL"/<| | V `---` >=^ V | | | | | | | ^===="LOL"======<=="LOL"==< ^====="LOL"====< | ^==================< Added the center of the "O" One important note here might be "anything that will not be processed, is a comment." Although, it may be possible to write messages in the code that is not related to the code but still used as operators @All The interpreter has been updated to include a new "operator". I had some individuals ask for a way to create functions or even sections of code that could be reused by referencing them rather than rewriting them So, I have added an operator that allows you to process code at another location. Code ended going upward | | >=====[xcoord,ycoord]====Code ended going rightward | | | | | Code ended going downward | Code ended going leftward The operator points to a coordinate to start the new code (going rightward), the code can modify the buffer and pointer positions and do about anything. The code is ended with "!". The ending direction of the code determines which path is used from this operator (relative to the calling code): rightward is no change to direction, downward is clockwise, leftward is backwards (or cw/ccw twice), upwards is counter-clockwise. The operator uses Down (clockwise from original direction) of the left bracket to signify "Backwards" because otherwise it would be very difficult to redirect the code. This allows you to create a switch from a code segment and to reuse code segments multiple times without the need to rewrite them or recreate them in different directions. Here is an example:>==v >==="up"\\./.===============! | | | | >===[1,13]==="right"\\\\\././././.===! | | | | | >==="down"\\\\./././.=======! | >========"left"\\\\./././.=======! Code Segment [1,13] >==v | | | >======v | | !==< Displays "left" (relative direction: Backwards) This may be a little complicated to take in at first, but it should make your AutoBoat life easier. Edited July 28, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
crashdemons Posted March 31, 2010 Author Posted March 31, 2010 (edited) The previous post is now fixed. It appears that the "Visual RTE Editor" mode (User CP>Settings>General>Posting) likes to eat extra spaces; I like that forum feature - but it's going to make posting AutoBoat code horribly difficult. So, I am now back to using the plain standard editor. Edit: fixed a bug with multiple uses of the coordinate operator. Edited March 31, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
corgano Posted April 1, 2010 Posted April 1, 2010 What if it used a "light and mirror" method - No paths for the circut, just the directional operators? So that: >=====V >=====V ^ | >=="LOL"==V ^ | | " | | | | | L | .---. | | | " O | | | | | | L L | | | | | | O " | | | | | | L | ^ | | | | | >=V " >======>==\< | | | | >==="LOL"/<| | V `---` >=^ V | | | | | | | ^===="LOL"======<=="LOL"==< ^====="LOL"====< | could be expressed as: > V > V ^ > "LOL" V ^ " L .---. " O L L O " L ^ > V " > > \< > "LOL"/< V `---` > ^ V ^ "LOL" < "LOL" < ^ "LOL" < 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
crashdemons Posted April 1, 2010 Author Posted April 1, 2010 (edited) What if it used a "light and mirror" method - No paths for the circut, just the directional operators? So that: >=====V >=====V ^ | >=="LOL"==V ^ | | " | | | | | L | .---. | | | " O | | | | | | L L | | | | | | O " | | | | | | L | ^ | | | | | >=V " >======>==\< | | | | >==="LOL"/<| | V `---` >=^ V | | | | | | | ^===="LOL"======<=="LOL"==< ^====="LOL"====< | could be expressed as: > V > V ^ > "LOL" V ^ " L .---. " O L L O " L ^ > V " > > \< > "LOL"/< V `---` > ^ V ^ "LOL" < "LOL" < ^ "LOL" < You could accomplish that by modifying AutoBoat.au3: remove the section for Case ' ', add ' ' to Case '=','|' (Case '=','|',' ') as below and in contrast to the original code. ... Switch $cmd Case '!' $ret=-1 ;Exit(0) Case '' MsgBox(16,'AutoBoat Error','Destination Coordinate ['&$Coord[0]&','&$Coord[1]&'] out-of-bounds.') Exit(2) Case '=','|',' ' ; do nothing $ex=0 ... However, I like having paths so I can trace the code visually. This also helps me distinguish needed characters from missing characters. (whitespace and *nothing* appear the same visually in most cases) On the other hand, the above change would allow you to choose whether to use |,=, or just a Space. Another negative though, if spaces became connectors - the notification for an "Open circuit at (x,y)" would no longer occur to let you know when you accidentally messed up and pointed your code in a direction you didn't want it to go in. You would be on your own if your code ran amok. I'm not sure I see the Pros of your approach, aside from being able to see only the "important" operators - but without seeing the context of the path, they're meaningless; seeing the path could be difficult in more complicated code in that form. - but feel free to modify the interpreter as you want. Edited April 1, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
crashdemons Posted June 8, 2010 Author Posted June 8, 2010 (edited) Updated the interpreter, documentation and test script.The interpreter now supports several operators regarding files (opening,creating,deleting,existence)You can now open file handles and set the Input/Output to a handle to make a file the destination of any output, or the source of input.You can now print a null/eof-terminated string starting at the 'current byte' (under the pointer) in the buffer with an operator, and be able to move back to the first byte of the previous "" string entered with one operator.See the AutoBoat.txt for specific documentation.test.txt has been updated with a File Create/Write/Read/Delete example with some minor failure checking.>==".\createfile.dat"0$s==`wo=="This is a file test. Char: "0$s==0+F4./" ("0$s\#")"$.==,==0o==[1,15]==! || || |>==0+oA."File could not be opened for writing."0$s==! >==0+oA."File could not be created."0$s==! AutoBoat script by CrashDemons v========< | | | | >=0+A/"Reading File: "0+A/0$\s==".\createfile.dat"0$==ri==>==:==.==^==>===;$"."$~==! | | | | | | | >========^ | >==0+o"File could not be opened for reading."0$s==!The test script creates a file, opens it for writing and writes some text to it via the Output operators, then closes it. Next it opens it for reading and prints the contents to the console, then closes and deletes the file.As a further note you could use "" to mark a buffer position to return to with $ without modifying the buffer. ( "" without any text will not advance the byte position)Some consideration may need to be done on whether some future operations need adding:- Return to buffer position based on the value of the current byte.- Open file with custom flags (either requires two bytes or overwriting the flag byte)- Jump to code coordinates based on the current byte(s) rather than typed ones.- etcI can add most reasonable operators, but an unused symbol or letter will need to be chosen for the operation.Feel free to add any suggestions. Edited June 9, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
crashdemons Posted July 27, 2010 Author Posted July 27, 2010 (edited) Edit: Updated posted code link (human error ) Edit: Another incorrect link (user instead of topic) I've been doing some checking and I *think* it should be possible to convert programs made in Brainfuck to AutoBoat (this language). If that can be done reliably, it would seem AB could be Turing-Complete. (Because Brainfuck is a Turing Tarpit) What does it mean? It means you should be able to manipulate AB to find almost any calculation (given you stay within its buffer limit) - It's Not so Useless After-All!!! Here are the specs on how I think you can convert BF to AutoBoat: expandcollapse popupBrainFuck | AutoBoat > | / < | \ + | + - | - . | . ------------------------------------------- Special Cases: Brainfuck operator = , AutoBoat equivalent = :> >^ Reason = AutoBoat's input operator is identical except that it turns clockwiseon Null, so code has been added for flow correction. ------------------------------------------- Special Case: Brainfuck operators = [ and ] Reason = There are no stack jump-forward/back, but it can be simulated exactly with by using flow operators Notes = code can be resized to contain itself (see third example equivalent to X[ABC]Y v==========< | | | | >==X==%==>==ABC==%==^==>==Y==> | | | | | | | >=====^ | | >================^ or v====< >==X%>ABC%^>Y==> | >=^ >======^ equivalent to [[A]B] v=================< | | | v==< | >=====%==>===%>A%^>==B==%==^==>===> | | >=^ | | | >====^ | | | >=====^ | | >=======================^(also posted here: http://codepad.org/YN52S4Vw) I'll try a couple BF programs in the mean time Sub-rant on brackets: I did notice a few code posts for BF interpreters, including one on these forums; However, many (including this one) seem to neglect the fact that the left bracket "[" matches "]" hierarchically, meaning "[[]]" is valid BF code where the outside brackets match and the inside brackets match; the ones who neglect this end up with the first "[" matching the first "]" or "[[]]". *[ and ] match as parentheses usually do: each [ matches exactly one ] and vice versa, the [ comes first, and there can be no unmatched [ or ] between the two. Edited August 8, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
crashdemons Posted July 27, 2010 Author Posted July 27, 2010 (edited) Brainfuck -> AutoBoat conversions (using above document)If I do any conversions, I'll be posting them here."Hello World!" (from Wikipedia):BF: ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.AB: (tested) V v===============================< >==>++++++++++%>/+++++++/++++++++++/+++/+\\\\-%^>/++./+.+++++++..+++./++.\\+++++++++++++++./.+++.------.--------./+./.>==! | >=^ >=================================^Single-digit integer-division (hit two number keys for a result) from WikipediaBF: ,>,>++++++[-<--------<-------->>]<<[>[->+>+<<]>[-<<-[>]>>>[<[>>>-<<<[-]]>>]<<]>>>+<<[-<<+>>]<<<]>[-]>>>>[-<<<<<+>>>>>]<<<<++++++[-<++++++++>]<.AB: (tested) V v=================================================================================< | | v==========================================< | | | | v======================< | | | | | | v==============< | | | | v======================< | v========< | v==< | | v==< | | | v=======< | v==< v=============< v============< >==>:>/:>/++++++%>-\--------\--------//%^>\\%>/%>-/+/+\\%^>/%>-\\-%>/%^>///%>\%>///-\\\%>-%^>%^>//%^>\\%^>///+\\%>-\\+//%^>\\\%^>/%>-%^>////%>-\\\\\+/////%^>\\\\++++++%>-\++++++++/%^>\.>==! >^ >^ | >=^ | | >=^ | | >=^ | | | >=^| | | | | | | >=^ | | | >=^ | >=^ | >=^ >========================^ | >==========^ | >====^ | | >====^| | | | | | >=========^ | | >====^ >===============^ >==============^ | | | | >=^ | | | | | | | | | >================^ | | | | | | | | | >=^ | | | | | | >========================^ | | | | | | >=^ | | | >============================================^ | | | >=^ >===================================================================================^99 Bottles of BeerBF: http://99-bottles-of-beer.net/language-brainfuck-101.htmlAB: (tested) http://codepad.org/BhReNe3sThis script should convert BF code to an AB code fine. (notice: you can change the Action_* flag variables to decide how/if to handle certain errors.)expandcollapse popup#include <String.au3> #include <Array.au3> Global Const $BF2AB_Unhandled=0 Global Enum Step *2 $BF2AB_Debug,$BF2AB_Exit,$BF2AB_Ignore,$BF2AB_Input_ReadFromCon; you can BitOr together Debug and Ignore or Exit Global $BF2AB_Action_UpperPointerBoundary=$BF2AB_Unhandled Global $BF2AB_Action_LowerPointerBoundary=$BF2AB_Unhandled Global $BF2AB_Action_InputEOF=$BF2AB_Ignore; because BF ignores it. Global $BF2AB_AppendComments=False Local $f1=FileOpenDialog('BF2AB - Open BrainFuck script',@ScriptDir,"BrainFuck Scripts (*.bf;*.b)|All Files (*.*)",1) If @error=0 Then Local $BF=FileRead($f1) If @error=0 Then Local $AB=BF2AB_Complete($BF) Local $f2=FileSaveDialog('BF2AB - Save AutoBoat script',@ScriptDir,"AutoBoat Scripts (*.ab;*.txt)|All Files (*.*)",1) If @error=0 Then Local $fh=FileOpen($f2,2) If $fh>-1 Then If FileWrite($f2,$AB)=0 Then MsgBox(16,'BF2AB Error','File Write failed.') Else MsgBox(16,'BF2AB Error','File Open failed.') EndIf EndIf Else MsgBox(16,'BF2AB Error','File Read failed: '&@error) EndIf EndIf Exit Func BF2AB_Complete(ByRef $Data) Local $Comments=StringRegExpReplace($Data,'[\<\>\+\-\.\,\[\]]','') $Data=StringStripWS($Data,8) $Data=StringRegExpReplace($Data,'[^\<\>\+\-\.\,\[\]]','') Local $ReadFromCon=BitAnd($BF2AB_Action_InputEOF,$BF2AB_Input_ReadFromCon)=$BF2AB_Input_ReadFromCon Local $b Local $sOps=BF2AB($Data,$b) Local $Dim=_String_GetDimensions($sOps) Local $leftpad=-4 If $ReadFromCon Then $leftpad-=13 sBuf_SetOperator($sOps,$b, 0,$leftpad,' '); left pad For $i=1 To $b Switch $i Case 1 If $i=$b Then sBuf_SetOperator($sOps,$i,0, 1,'!') Else sBuf_SetOperator($sOps,$i,0, 1,'V') EndIf Case $b sBuf_SetOperator($sOps,$i,0, 1,'>==>') If $ReadFromCon Then sBuf_SetOperator($sOps,$i,0, 5,'"con"0$ri>==>') Local $j=$i+1 sBuf_SetOperator($sOps,$j,0, 5,' >=^') EndIf sBuf_SetOperator($sOps,$b, 0,$Dim[0]+(-$leftpad)+1,'>==!') Case Else sBuf_SetOperator($sOps,$i,0, 1,'|') EndSwitch Next If $BF2AB_AppendComments Then $sOps&=@LF&@LF&$Comments Return StringReplace(StringStripCR($sOps),@LF,@CRLF) EndFunc Func BF2AB(ByRef $Data,ByRef $b, $r=0) Local $t=_StringRepeat(' ',$r) ConsoleWrite($t&$r&' { '&$Data&@CRLF) $Data=StringReplace(StringReplace(StringReplace($Data,'<','\'),'>','/'),',',':') Local $Stack[1]=[0] Local $Open=0 Local $s='' $b=1 Local $pb=1 For $p=1 To StringLen($Data) Local $Operator=StringMid($Data,$p,1) Switch $Operator Case '[' $Open+=1 ReDim $Stack[$Open+1] $Stack[$Open]=$p Case ']' If $Open>0 Then Local $pOpen=$Stack[$Open] ReDim $Stack[$Open] $Open-=1 If $Open=0 Then ConsoleWrite($t&$r&' ::'&$Open&' '&StringMid($Data,$pOpen,($p-$pOpen)+1)&@CRLF) Local $pStart=($pOpen+1) Local $subLen=(($p-1)-$pStart)+1 Local $sub=StringMid($Data,$pStart,$subLen) Local $subB Local $subconvert=BF2AB($sub,$subB,$r+1) ConsoleWrite($t&$r&' :: s'&$subB&@CRLF&$subconvert&@CRLF) Local $subW,$subH,$subOff $subconvert=BF2AB_BracketConv($subconvert, -($subB-1), $subW,$subH,$subOff) Local $aconvert=StringSplit($subconvert,@LF) For $i=1 To UBound($aconvert)-1 sBuf_SetOperator($s,$b,$subOff+($i-1),$pb,$aconvert[$i]) Next $pb+=$subW ConsoleWrite($t&$r&' :: '&$b&@CRLF&$subconvert&@CRLF) EndIf Else MsgBox(16,'BF2AB Error','Error: Closing bracket encountered without matching opening bracket.'&@CRLF&'Please ensure your BrainFuck code is correct.') EndIf Case Else If $Open=0 Then Switch $Operator Case ':' BF2AB_SetHandler($Operator, $BF2AB_Action_InputEOF, $s, $b, $pb) Case '/' BF2AB_SetHandler($Operator, $BF2AB_Action_UpperPointerBoundary, $s, $b, $pb) Case '\' BF2AB_SetHandler($Operator, $BF2AB_Action_LowerPointerBoundary, $s, $b, $pb) Case Else sBuf_SetOperator($s,$b, 0,$pb,$Operator) $pb+=1 EndSwitch EndIf EndSwitch Next If $Open>0 Then MsgBox(16,'BF2AB Error','Error: Not all open brackets have been closed.'&@CRLF&'Please ensure your BrainFuck code is correct.') Return $s EndFunc Func BF2AB_SetHandler(ByRef $Operator, ByRef $Action, ByRef $s, ByRef $b, ByRef $pb) If $Action=$BF2AB_Unhandled Then sBuf_SetOperator($s,$b, 0,$pb,$Operator) $pb+=1 Else Local $Ignore=BitAnd($Action,$BF2AB_Ignore)=$BF2AB_Ignore Local $Debug=BitAnd($Action,$BF2AB_Debug)=$BF2AB_Debug Local $Exit=BitAnd($Action,$BF2AB_Exit)=$BF2AB_Exit Local $ReadFromCon=BitAnd($Action,$BF2AB_Input_ReadFromCon)=$BF2AB_Input_ReadFromCon Local $OpLine =$Operator Local $CatchLine='' If $ReadFromCon And $Operator=':' Then $Ignore=True If $Debug Then $OpLine&= '================>' $CatchLine&='>"BF2AB_ERR:'&$Operator&'"0$s' If $Exit Then $CatchLine&='!' Else If $Ignore Then $CatchLine&='^' EndIf Else If $Exit Then $CatchLine&='!' Else If $Ignore Then $OpLine&= '>' $CatchLine&='>^' EndIf EndIf EndIf sBuf_SetOperator($s,$b, 0,$pb,$OpLine) sBuf_SetOperator($s,$b, 1,$pb,$CatchLine) $pb+=StringLen($OpLine) EndIf EndFunc Func BF2AB_BracketConv($sOps, $OpsOff, ByRef $ConvW, ByRef $ConvH, ByRef $ConvOff) If $OpsOff>0 Then $OpsOff=0 Local $b=1+(-$OpsOff) Local $Dim=_String_GetDimensions($sOps) Local $WidthPadding,$TopPadding,$BottomPadding $WidthPadding=$Dim[0] $TopPadding-=$OpsOff; make sure >=0 $BottomPadding=($Dim[1]-1)+$OpsOff sBuf_SetOperator($sOps,$b, 0,-2,' '); to set the prepadding sBuf_SetOperator($sOps,$b,$OpsOff-1, 2, 'v'&_StringRepeat('=',$WidthPadding)&'=<') For $i=1 To $TopPadding sBuf_SetOperator($sOps,$b,-$i, 2,'|') sBuf_SetOperator($sOps,$b,-$i, 4+$WidthPadding,'|') Next sBuf_SetOperator($sOps,$b, 0, 1,'%>') sBuf_SetOperator($sOps,$b, 0, 3+$WidthPadding,'%^>') For $i=1 To $BottomPadding sBuf_SetOperator($sOps,$b,+$i, 1,'|') sBuf_SetOperator($sOps,$b,+$i, 3+$WidthPadding,'|') sBuf_SetOperator($sOps,$b,+$i, 5+$WidthPadding,'|') Next sBuf_SetOperator($sOps,$b,$BottomPadding+1, 1, '| '&_StringRepeat(' ',$WidthPadding)&'>=^') sBuf_SetOperator($sOps,$b,$BottomPadding+2, 1, '>='&_StringRepeat('=',$WidthPadding)&'==^') $Dim=_String_GetDimensions($sOps) $ConvW=$Dim[0] $ConvH=$Dim[1] $ConvOff=-($b-1) Return $sOps EndFunc Func _String_GetDimensions(ByRef $sOps) Local $Dim[2]=[0,0] Local $aOps=StringSplit($sOps,@LF) $Dim[1]=UBound($aOps)-1 For $i=1 To $Dim[1] Local $Len=StringLen($aOps[$i]) If $Dim[0]<$Len Then $Dim[0]=$Len Next Return $Dim EndFunc Func sBuf_SetLines(ByRef $sBuf,ByRef $aBuf,ByRef $uMax,ByRef $iBaseline,$iLineRel,ByRef $iPos,ByRef $iLine_out) $iLine_out=$iBaseline+$iLineRel If $iLine_out<1 Then While $iLine_out<1 $sBuf=@LF&$sBuf ;MsgBox(0,'x','|'&$sBuf&'|') $iLine_out+=1 $iBaseline+=1 $uMax+=1 WEnd $aBuf=StringSplit($sBuf,@LF) EndIf If $iLine_out>$uMax Then While $iLine_out>$uMax $sBuf&=@LF $uMax+=1 WEnd $aBuf=StringSplit($sBuf,@LF); baseline didn't change EndIf If $iPos=0 Then $iPos=1 If $iPos<0 Then Local $prepad=_StringRepeat(' ',-$iPos) $iPos=1 For $i=1 To $uMax $aBuf[$i]=$prepad&$aBuf[$i] Next EndIf EndFunc Func sBuf_SetOperator(ByRef $sBuf,ByRef $iBaseline,$iLineRel,$iPos,$sOp) Local $aBuf=StringSplit($sBuf,@LF) Local $uMax=UBound($aBuf)-1 Local $iLine sBuf_SetLines($sBuf,$aBuf,$uMax,$iBaseline,$iLineRel,$iPos,$iLine) ;sBuf_PadLines($aBuf,$uMax) Local $lOp=StringLen($sOp) Local $iLen=StringLen($aBuf[$iLine]) Select Case $iLen<($iPos-1) $aBuf[$iLine]=$aBuf[$iLine]&_StringRepeat(' ',($iPos-1)-$iLen)&$sOp Case $iLen=($iPos-1) $aBuf[$iLine]=$aBuf[$iLine]&$sOp Case $iLen=$iPos $aBuf[$iLine]=StringLeft($aBuf[$iLine],$iPos-1)&$sOp Case $iLen>$iPos $aBuf[$iLine]=StringLeft($aBuf[$iLine],$iPos-1)&$sOp&StringMid($aBuf[$iLine],$iPos+$lOp) EndSelect ;_ArrayDisplay($aBuf) $sBuf='' For $i=1 To $uMax If $i=$uMax Then $sBuf&=$aBuf[$i] Else $sBuf&=$aBuf[$i]&@LF EndIf Next EndFuncEdit: Input wasn't being converted, now it is.Edit: Script now removes comments (ignored characters) from BF code before conversion [10:02 AM 7/28/2010]Edit: Script now has an option to append comments in the BF code to the end of the AB code. [1:59 PM 7/28/2010] Edited July 28, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
corgano Posted July 28, 2010 Posted July 28, 2010 Damn. That looks vicious. Like the script would eat small children or something. Good work! 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now