Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/15/2017 in all areas

  1. You shouldn't need to use Call at all. You can create variables containing a function datatype assigned to whatever function name you want, on the fly: Local $MyFunc = "_Te" Execute('Assign("d", ' & $MyFunc & 'st)') ConsoleWrite("$d is a " & VarGetType($d) & @LF) Of course you need Func _Test(...) declared somewhere in the script, possibly with ByRef parameters. Is that what you need? Or what am I missing?
    1 point
  2. Remember : lookahead and lookbehind assertions are not-capturing, so "$2" matches nothing Could also be written like this $a = StringRegExpReplace($a, '(?<=\$(?|40|45|120):)\R(?=\$%\$\?\$%)', "") which means : match \R preceded by .. and followed by .. and delete it You could even try $a = StringRegExpReplace($a, '(?<=\$(\d{2}|\d{3}):)\R(?=\$%\$\?\$%)', "") which means : match \R preceded by ($ and 2 or 3 digits and colon) and followed by ... etc If you start falling into a regex addiction I strongly suggest to re-read the helpfile page and look for the lookaround features - and some other very useful things
    1 point
  3. VeryGut, Welcome to the AutoIt forums. You can indeed use a function in an array - like this: #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "_Exit") Global $Array[5] = ["5", "4", _Function2, "2", "1"] While 1 _Function1() WEnd Func _Function1() For $i = 0 To 4 MsgBox($MB_OK, "", ( (IsFunc($Array[$i])) ? ($Array[$i]()) : ($Array[$i]) )) Next EndFunc ;==>_Function1 Func _Function2() Return "Function was executed" EndFunc ;==>_Function2 Func _Exit() Exit EndFunc You need to check that the array element is a function and then add the trailing () to execute it. Out of interest, why do you need to do this? M23
    1 point
  4. ((?<!^|:)(?=\$%\$\?\$%)) (?<! ...) = not preceded by ... (?= ...) = followed by ... both are zero-length assertions, they don't capture and match a position (?<!^|:) = with the alternation, means not preceded by ^ (beginning of text) or : (colon)
    1 point
  5. Because you didn't read the responses prior to yours. Reread them now.
    1 point
  6. Laurynelis, You need to use GUICtrlRead to get the value of the control - at present you are getting the ControlID of the label control itself. ConsoleWrite(GUICtrlRead($Label1)) M23
    1 point
  7. You need to use ConsoleWrite(GuiCtrlRead($Label1) & @CRLF)
    1 point
  8. sandyd, I recently posted some examples here - any use? M23
    1 point
  9. mikell

    Allow +/- numbers

    $ES_NUMBER doesn't allow minus/dot Maybe this ? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> GUICreate("Input Filter", 300, 30, -1, -1) Global $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord Local $iCode = BitShift($wParam, 16) ;HiWord If $iIDFrom = $inTest And $iCode = $EN_CHANGE Then $Read_Input = GUICtrlRead($inTest) If not StringRegExp($Read_Input, '^[\d-]?\d*(?:\.\d*)?$') Then GUICtrlSetData($inTest, StringTrimRight($Read_Input, 1)) Else GUICtrlSetData($inTest, StringRegExpReplace($Read_Input, '^(-?)\.', '${1}0.')) EndIf EndIf EndFunc;==>_WM_COMMAND
    1 point
  10. Back to the headlock You nicely pointed out the problem : how to make regex versatile enough to work on all files BUT secure enough to get invariable results For $T & $F in Example 2 , footnotes can be first deleted selectively, then the newlines can be inserted including an additional condition ($T not preceded by $F) For Example 3, to match both "$=<$=T3*1" and "$=<$=T4*42_USC_300AA-11" the expression may be done a bit less selective : (T\d\*\S+\s*) this should work as long as the sequences to match end with a space Sooo... version 2 : FileDelete(@ScriptDir & '\output.txt') $a = FileRead(@ScriptDir & '\ahihi.txt') ; delete footnotes, selective $a = StringRegExpReplace($a, '(\$%\$\?\$%[\s-]+(End\s+)?Footnotes[\s-]+)', "") ; insert a newline before $00, $T etc if they are not preceded by start of text, colon or $F $a = StringRegExpReplace($a, '(?<!^|:|\$F)(?=\$(?|00|01|03|10|20|25|30|40|45|110|115|120|F|T|200|220))', @crlf) ; delete all content behind $00: and \$200: $a = StringRegExpReplace($a, '(?<=\$00:|\$200:).+', "") ; delete whole lines $01, $03, $30 including newlines $a = StringRegExpReplace($a, '\$(?|01|03|30):.+\R', "") ; delete $=< , $=T3*1 , $=T4*42_USC_300AA-11 , $=L01836000613000341*000341 , $=P1298*n , $=> $a = StringRegExpReplace($a, '\$=(?|<|(T\d\*\S+\s*)|([LP]\d+\*\d+)|>)', "") ; insert a newline before $%$?$% , and before $T & $M if preceded by letter+colon $a = StringRegExpReplace($a, '(?=\$%\$\?\$%)|((?<=[a-z]:)(?=\$[TM]))', @crlf) ; move $=S from end of line to start of next line $a = StringRegExpReplace($a, '(\$=S)(\R)', "$2$1") ; OPTIONALS ; replace unwanted newlines in text parts by a horizontal space $a = StringRegExpReplace($a, '(\$T|\$%\$\?\$%)\V+?\K(?<=\w|\.)\R(?=\h?\w)', " ") ; replace multi horizontal spaces by only one $a = StringRegExpReplace($a, '\h+', " ") ; remove horizontal space between $I and $U $a = StringRegExpReplace($a, '(?<=\$I)\h+(?=\$U)', "") FileWrite("output.txt", $a)
    1 point
  11. 1 point
×
×
  • Create New...