Leaderboard
Popular Content
Showing content with the highest reputation on 08/30/2014 in all areas
-
Hi there. Abstract This UDF enables the use of all reference APL features in AutoIt. Is uses the original APL symbols. The code is interpreted via a sandbox ngn-apl interface which relies on JavaScript. Execution is done via IE objects. What's APL? APL is a formal, imperative language. Because it is imperative, a sentence may be called an instruction, and may be executed to produce a result. StringAPL() has one main parameter, which is the APL source code. Thus: StringAPL("2×(3+4)") = "14"Unlike traditionally structured programming languages, code in APL is typically structured as chains of monadic or dyadic functions and operators acting on arrays. As APL has many nonstandard primitives (functions and operators, indicated by a single symbol or a combination of a few symbols), it does not have function or operator precedence. The APL environment is called a workspace. In a workspace the user can define programs and data, i.e. the data values exist also outside the programs, and the user can manipulate the data without the necessity to define a program. For example, StringAPL("N ← 4 5 6 7")will initialize a vector "N" containing 4 elements according to the command. After each StringAPL call, the workspace is deleted completely, so you have to use multi-instructions if you want to reuse macros, functions or variables. Now that we have "N" we can manipulate it. Here's just a small example, you can do much more with APL (later more): N+4Will perform an addition. Every element in N is increased by (int)4. Easy, at least for now ;-) What's possible? Everything. If you feel like it, just draw a mandelbrot fractal using only one line 'o code. Or solve the n-Queen problem, or determine the first hundred prime numbers, or parse a html file. APL is like RegEx on crack. Some really advanced examples are included within the example file. Now, why isn't APL more popular? Because it uses a very, very strange charset. In fact, you have to install the APL Unicode font (https://sites.google.com/site/baavector/fonts) and set SciTe to use this font (CTRL+1 -> Change Monospace Font), before you can even view the examples! In addition to that, you scripts have to be UTF8 BOM encoded, which in return causes Au3Check to crash whenever custom includes are used. I'm planning on replacing the APL chrs with hum-readable english commands, but that may take some time :-) Just look at the mandelbrot drawing code, it's absolutely ridiculous!: I'd call it abstract art . Examples There are a few examples included. For the basic stuff please visit the Wikipedia APL page und Wikipedia APL reference: Remarks Please do not use the second parameter yet, it is unfinished and experimental. Also, to use multiline-code, use . in-command to start a new line, just like the examples. Download Example file (INSTALL APL FONT AND ENCODE UTF8BOM!!!) UDF (doesn't need any special treatment, doesn't contain APL chrs) https://github.com/Perseus-Developers/StringAPL Does not work in 3.3.9.5. Developed in 3.3.8.1. No further testing, please report bugs only if they occur in a stable version.1 point
-
Very nice! You have all APL specific characters in the DejaVu Sans Mono (it is perfect for most fixed-pitch uses, e.g. editors).1 point
-
dushkin, That sounds a lot like a spam script - would you care to explain why it is not? M231 point
-
1 point
-
Hi, After a protracted development period (we were both away for periods) I have managed to produce something which meets remin's many and complex requirements - so I thought I would post a boilerplate version here in case anyone looking was interested and wanted to modify it for their own needs. First off, you will need a v3.3.13.# Beta version to run the code as it uses maps. A few words of explanation. remin wanted to wrap a lot of small scripts he had developed into one large package with each actioned by a HotKey. But he was having problems integrating them all as some of the scripts used small dialogs and he could not get them to work nicely together. As I explained earlier in the thread, this is because each of the scripts when called interrupted the current one and AutoIt was getting confused. The solution I adopted was to break each of the existing scripts into 3 parts: creation, action, deletion. Then the wrapper script calls these sections when required, using maps to determine whether a dialog is active, has been actioned, or should be deleted. There was also a requirement to reactivate the previously active window when the dialogs were action, to store the positions of the dialogs on exit or when moved, and to allow {ESC} to close them. Here is what I finally came up with - I have commented liberally so I hope you can follow what is going on: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #NoTrayIcon Global $mDialog[] ; Map to hold open dialog handles ; Functions which have a GUI HotKeySet("^6", "_Script_6") ; Hotkey to activate dialog Global $mScript_6[] ; Map to hold dialog handle and ControlIDs HotKeySet("^7", "_Script_7") Global $mScript_7[] HotKeySet("^8", "_Script_8") Global $mScript_8[] ; Functions which do not have a GUI HotKeySet("^1", "Script_1") ; HotKey to action function HotKeySet("^2", "Script_2") Global $gLastDialog = 0 ; Last active dialog Global $gMyINI = "Dialog.ini" ; Ini file Global $gActiveWin = 0 ; Handle of active window other than dialogs HotKeySet("!^{ESC}", "_Exit") ; HotKey to exit script HotKeySet("{ESC}", "_CloseLast") ; HotKey to exit last active dialog Opt("GUIEventOptions", 1) ; Prevent autoclosing of dialogs ; Register message to detect when dialogs moved GUIRegisterMsg($WM_EXITSIZEMOVE, "_Dialog_Moved") ; Start timer $nBegin = TimerInit() While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $mScript_6["Dialog"] ; Onlt check the dialog for events if it has been activated _Check_Script_6($aMsg[0]) Case $mScript_8["Dialog"] _Check_Script_8($aMsg[0]) Case $mScript_7["Dialog"] _Check_Script_7($aMsg[0]) EndSwitch ; Check for current active window other than dialogs If TimerDiff($nBegin) > 250 Then _GetActive() ; Reset timer $nBegin = TimerInit() EndIf WEnd Func _Script_6() ; Called when HotKey is pressed If Not MapExists($mScript_6, "Dialog") Then ; Create the dialog if it does not exist _Create_Script_6() EndIf EndFunc ;==>Script_6 Func _Create_Script_6() ; Get the current active window - just in case _GetActive() ; Determine the coordinates to use Local $iX = IniRead($gMyINI, "POS_Script_6", "x", 100) Local $iY = IniRead($gMyINI, "POS_Script_6", "y", 100) ; Create the dialog $hDialog = GUICreate("Script_6", 200, 200, $iX, $iY, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) ; Save the dialog handle $mScript_6["Dialog"] = $hDialog $mDialog["Script_6"] = $hDialog $gLastDialog = $hDialog ; Add controls ad store the ControlIDs $mScript_6["One"] = GUICtrlCreateButton("Script_6 1", 10, 10, 80, 30) $mScript_6["Two"] = GUICtrlCreateButton("Script_6 2", 10, 50, 80, 30) GUISetState(@SW_SHOWNOACTIVATE, $hDialog) ; Reactivate the current window - just in case WinActivate($gActiveWin) EndFunc ;==>_Create_Script_6 Func _Check_Script_6($iMsg) Switch $iMsg Case $GUI_EVENT_CLOSE _Delete_Script_6() Case $mScript_6["One"] To $mScript_6["Two"] ; Reactivate the previously active window WinActivate($gActiveWin) $gLastDialog = $mScript_6["Dialog"] Switch $iMsg Case $mScript_6["One"] ; Add required code here ConsoleWrite("Script_6 Button 1 pressed" & @CRLF) Case $mScript_6["Two"] ConsoleWrite("Script_6 Button 2 pressed" & @CRLF) EndSwitch EndSwitch EndFunc ;==>_Check_Script_6 Func _Delete_Script_6() ; Save current dialog position IniWrite($gMyINI, "POS_Script_6", "x", WinGetPos($mScript_6["Dialog"])[0]) IniWrite($gMyINI, "POS_Script_6", "y", WinGetPos($mScript_6["Dialog"])[1]) ; Delete dialog GUIDelete($mScript_6["Dialog"]) ; Remove from maps MapRemove($mScript_6, "Dialog") ; Now the dialog will be recreated when the HotKey is nexxt pressed MapRemove($mDialog, "Script_6") ; Now the _Check_ function will not be run EndFunc Func _Script_7() ; Called when HotKey is pressed If Not MapExists($mScript_7, "Dialog") Then _Create_Script_7() EndIf EndFunc ;==>Script_6 Func _Create_Script_7() _GetActive() Local $iX = IniRead($gMyINI, "POS_Script_7", "x", 300) Local $iY = IniRead($gMyINI, "POS_Script_7", "y", 300) $hDialog = GUICreate("Script_7", 200, 200, $iX, $iY, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $mScript_7["Dialog"] = $hDialog $mDialog["Script_7"] = $hDialog $gLastDialog = $hDialog $mScript_7["One"] = GUICtrlCreateButton("Script_7 1", 10, 10, 80, 30) $mScript_7["Two"] = GUICtrlCreateButton("Script_7 2", 10, 50, 80, 30) GUISetState(@SW_SHOWNOACTIVATE, $hDialog) WinActivate($gActiveWin) EndFunc ;==>_Create_Script_7 Func _Check_Script_7($iMsg) Switch $iMsg Case $GUI_EVENT_CLOSE _Delete_Script_7() Case $mScript_7["One"] To $mScript_7["Two"] WinActivate($gActiveWin) $gLastDialog = $mScript_7["Dialog"] Switch $iMsg Case $mScript_7["One"] ConsoleWrite("Script_7 Button 1 pressed" & @CRLF) Case $mScript_7["Two"] ConsoleWrite("Script_7 Button 2 pressed" & @CRLF) EndSwitch EndSwitch EndFunc ;==>_Check_Script_7 Func _Delete_Script_7() IniWrite($gMyINI, "POS_Script_7", "x", WinGetPos($mScript_7["Dialog"])[0]) IniWrite($gMyINI, "POS_Script_7", "y", WinGetPos($mScript_7["Dialog"])[1]) GUIDelete($mScript_7["Dialog"]) MapRemove($mScript_7, "Dialog") MapRemove($mDialog, "Script_7") EndFunc Func _Script_8() ; Called when HotKey is pressed If Not MapExists($mScript_8, "Dialog") Then _Create_Script_8() EndIf EndFunc ;==>Script_8 Func _Create_Script_8() _GetActive() Local $iX = IniRead($gMyINI, "POS_Script_8", "x", 500) Local $iY = IniRead($gMyINI, "POS_Script_8", "y", 500) $hDialog = GUICreate("Script_8", 200, 200, $iX, $iY, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $mScript_8["Dialog"] = $hDialog $mDialog["Script_8"] = $hDialog $gLastDialog = $hDialog $mScript_8["One"] = GUICtrlCreateButton("Script_8 1", 10, 10, 80, 30) $mScript_8["Two"] = GUICtrlCreateButton("Script_8 2", 10, 50, 80, 30) GUISetState(@SW_SHOWNOACTIVATE, $hDialog) WinActivate($gActiveWin) EndFunc ;==>_Create_Script_8 Func _Check_Script_8($iMsg) Switch $iMsg Case $GUI_EVENT_CLOSE _Delete_Script_8() Case $mScript_8["One"] To $mScript_8["Two"] WinActivate($gActiveWin) $gLastDialog = $mScript_8["Dialog"] Switch $iMsg Case $mScript_8["One"] ConsoleWrite("Script_8 Button 1 pressed" & @CRLF) Case $mScript_8["Two"] ConsoleWrite("Script_8 Button 2 pressed" & @CRLF) EndSwitch EndSwitch EndFunc ;==>_Check_Script_8 Func _Delete_Script_8() IniWrite($gMyINI, "POS_Script_8", "x", WinGetPos($mScript_8["Dialog"])[0]) IniWrite($gMyINI, "POS_Script_8", "y", WinGetPos($mScript_8["Dialog"])[1]) GUIDelete($mScript_8["Dialog"]) MapRemove($mScript_8, "Dialog") MapRemove($mDialog, "Script_8") EndFunc Func Script_1() ; There is no dialog so just run the required code here ConsoleWrite("Script_1 running" & @CRLF) EndFunc ;==>Script_1 Func Script_2() ConsoleWrite("Script_2 running" & @CRLF) EndFunc ;==>Script_2 Func _GetActive() $hCurrent = WinGetHandle("[ACTIVE]") ; Are there are dialogs to check? If UBound($mDialog) Then For $vKey In MapKeys($mDialog) If $hCurrent <> $mDialog[$vKey] Then $gActiveWin = $hCurrent EndIf Next Else ; If not then change current $gActiveWin = $hCurrent EndIf EndFunc ;==>_GetActive Func _Dialog_Moved($hWnd, $iMsg, $wParam, $lParam) ; Reactivate the current window WinActivate($gActiveWin) EndFunc ;==>_Dialog_Moved Func _CloseLast() ; If no dialog has been activated since the last deletion If $gLastDialog = 0 Then ; Set a dialog by default Local $aKeys = MapKeys($mDialog) If UBound($aKeys) Then $gLastDialog = $mDialog[$aKeys[0]] EndIf EndIf ; Delete the last active dialog Switch WinGetTitle($gLastDialog) Case "Script_6" _Delete_Script_6() $gLastDialog = 0 Case "Script_7" _Delete_Script_7() $gLastDialog = 0 Case "Script_8" _Delete_Script_8() $gLastDialog = 0 EndSwitch EndFunc Func _Exit() If MapExists($mScript_6, "Dialog") Then IniWrite($gMyINI, "POS_Script_6", "x", WinGetPos($mScript_6["Dialog"])[0]) IniWrite($gMyINI, "POS_Script_6", "y", WinGetPos($mScript_6["Dialog"])[1]) EndIf If MapExists($mScript_8, "Dialog") Then IniWrite($gMyINI, "POS_Script_8", "x", WinGetPos($mScript_8["Dialog"])[0]) IniWrite($gMyINI, "POS_Script_8", "y", WinGetPos($mScript_8["Dialog"])[1]) EndIf If MapExists($mScript_7, "Dialog") Then IniWrite($gMyINI, "POS_Script_7", "x", WinGetPos($mScript_7["Dialog"])[0]) IniWrite($gMyINI, "POS_Script_7", "y", WinGetPos($mScript_7["Dialog"])[1]) EndIf Exit EndFunc ;==>_Exit I am not interested in developing the script further, so please do not ask for any further functionality - and if you want to produce another way of skinning this particular cat, please open another thread to do so. M231 point
-
Example and explaination in the script: #include <Array.au3> $sInput = 'Ashley R., Harris and Maxwell are going to the lake.' $sQuery = '((Ashley and R.) and (lake and not mountain)) and Harris and "and Maxwell"' ; -> There is a Person named Ashley ; -> Ashleys (or someones) surname is R. ; -> There is a lake, but no mountain ; -> There is a Person named Harris ; -> Maxwell should be the last person mentioned in this sentence ConsoleWrite("-> " & _StringMatch($sQuery, $sInput) & @LF) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringMatch ; Description ...: Returns wether the search pattern matches the given string. ; Boolean Operators, Brackets and Quotes can be used: ; Available OPs: and or not xor ; Brackets and even nested Brackets can be used (causes recursion). ; Use quotes to search for strings containing spaces ; Syntax ........: _StringMatch($sSearch, $sString) ; Parameters ....: $sSearch - The search pattern. ; $sString - A string value. ; Return values .: true or false ; Author ........: minx ; Example .......: s. above ; =============================================================================================================================== Func _StringMatch($sSearch, $sString) If $sSearch = "" Then Return SetError(1) Local $j[1], $b = 1 $s = _StringInStrRev($sSearch, "(") While 1 If $s > 0 Then $f = StringInStr($sSearch, ")", 0, 1, $s) If $f > 0 Then $sSearch = StringMid($sSearch, 1, $s - 1) & _StringMatch(StringMid($sSearch, $s + 1, $f - $s - 1), $sString) & StringMid($sSearch, $f + 1) EndIf $s = _StringInStrRev($sSearch, "(") If Not ($s > 0 And $f > 0) Then ExitLoop WEnd $i = StringSplit($sSearch, " ", 3) If StringInStr($sSearch, """", 0, 1, 1) Then For $a = UBound($i)-1 To 0 Step -1 If StringRight($i[$a], 1) = """" And StringLeft($i[$a], 1) <> """" Then $i[$a - 1] &= " " & $i[$a] $i[$a] = "" EndIf If StringRight($i[$a], 1) = """" And StringLeft($i[$a], 1) = """" And StringLen($i[$a]) > 1 Then $i[$a] = "!" & StringMid($i[$a], 2, StringLen($i[$a]) - 2) Next For $a = 0 To UBound($i)-1 If $i[$a] <> "" Then ReDim $j[$b] $j[$b - 1] = $i[$a] $b += 1 EndIf Next $i = $j EndIf For $a = 0 To UBound($i)-1 Switch StringUpper($i[$a]) Case "AND" $i[$a] = "AND" Case "OR" $i[$a] = "OR" Case "NOT" $i[$a] = "NOT" Case "XOR" $i[$a] = "XOR" Case "TRUE" $i[$a] = "true" Case "FALSE" $i[$a] = "false" Case Else If StringLeft($i[$a], 1) = "!" Then $i[$a] = StringMid($i[$a], 2) $i[$a] = StringLower(StringInStr($sString, $i[$a], 0, 1, 1) <> 0) EndSwitch Next $sSearch = _ArrayToString($i, " ") While 1 If StringInStr($sSearch, "NOT", 0, 1, 1) <> 0 Then $sSearch = StringReplace($sSearch, "NOT false", "true") $sSearch = StringReplace($sSearch, "NOT true", "false") EndIf If StringInStr($sSearch, "OR", 0, 1, 1) <> 0 Then $sSearch = StringReplace($sSearch, "false OR false", "false") $sSearch = StringReplace($sSearch, "true OR false", "true") $sSearch = StringReplace($sSearch, "false OR true", "true") $sSearch = StringReplace($sSearch, "true OR true", "true") EndIf If StringInStr($sSearch, "XOR", 0, 1, 1) <> 0 Then $sSearch = StringReplace($sSearch, "false XOR false", "false") $sSearch = StringReplace($sSearch, "true XOR false", "true") $sSearch = StringReplace($sSearch, "false XOR true", "true") $sSearch = StringReplace($sSearch, "true XOR true", "false") EndIf If StringInStr($sSearch, "AND", 0, 1, 1) <> "0" Then $sSearch = StringReplace($sSearch, "false AND false", "false") $sSearch = StringReplace($sSearch, "true AND false", "false") $sSearch = StringReplace($sSearch, "false AND true", "false") $sSearch = StringReplace($sSearch, "true AND true", "true") EndIf If StringInStr($sSearch, " ", 0, 1, 1) Then $sSearch = StringReplace($sSearch, "true true", "true") $sSearch = StringReplace($sSearch, "false true", "true") $sSearch = StringReplace($sSearch, "true false", "true") $sSearch = StringReplace($sSearch, "false false", "false") If StringInStr($sSearch, " ", 0, 1, 1) Then $sSearch &= " false" ContinueLoop EndIf EndIf ExitLoop WEnd Return $sSearch EndFunc Func _StringInStrRev($sString, $sSearch) $iPtr = StringLen($sSearch) For $nPos = StringLen($sString) - $iPtr To 1 Step -1 If StringMid($sString, $nPos, $iPtr) = $sSearch Then Return $nPos Next Return 0 EndFunc1 point
-
Hi there. This script is an implicit function plotter, plotting a graph that simulates a landscape. Basically, everything you see in this picture is based on implicit equations and functions. I modified the original equations a bit and added animation for the sea, a moving sun and two different kinds of lighting. Procedural Scene (only per-pixel-colors are calculated, no drawing function is used) Animated sea waves Animated sun Ambient light Directional light The animation has 60 Frames and runs @30FPS. The animation must be pre-buffered due the massive calculations done for every pixel, this takes approximately 5 minutes (get a coffee ). Here are the equations I used in the final version (don't change anythin in the script, except you want to redo all the math): Tree trunks: Light leaves: Dark leaves: Ground: Water: The Sun: Movement of the Sun: Calculation of the RGB values: If you really can't wait 5 minutes for the animation to calculate, here is a GIF (rendered with GDI+): Have fun LandScape.au31 point