guinness Posted March 16, 2013 Share Posted March 16, 2013 Here is an error I found in your workaroundThat's correct, I don't want any reference of $j in the nested loops as I want to create a list of variables in the function, plus that's bad coding practice using $j in that way.I will have a look at your implementation. Thanks. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
czardas Posted March 16, 2013 Share Posted March 16, 2013 (edited) Do you wish to remove variables used as the iteration count in a For Loop, but also appearing outside the loop? If so, do you intend to ignore variables explicitly declared outside the For loop? What do you intend to do if a global is used as the loop iteration count variable - assuming people will do stuff like this? Edited March 16, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
guinness Posted March 16, 2013 Share Posted March 16, 2013 Do you wish to remove variables initiated in a For Loop, but also appearing outside the loop?No, if people use them outside the For loop then that's their issue. I'm trying to improve the exporting feature of SciTE Jump. Same goes for those who declare Global variables in a function. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
czardas Posted March 16, 2013 Share Posted March 16, 2013 (edited) My point is how do you intend to differentiate between Local $i and Global $i when faced with just the function? I don't mean to be picky, I'm just trying to understand exactly what you want to do. Edited March 16, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
guinness Posted March 16, 2013 Share Posted March 16, 2013 Ah, I strip all functions first and then capture '$vVar =' instances to an array. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
czardas Posted March 16, 2013 Share Posted March 16, 2013 (edited) Ah, I strip all functions first and then capture '$vVar =' instances to an array. Hmm ok. What about something like this? - strange as it is! Global $i ModifyGlobal() Func ModifyGlobal() Local $iStop = 10 For $i = $i To $iStop Step 2 ConsoleWrite($i & @LF) Next ;$i = "" EndFunc Another more likely scenario to consider (if you haven't done so already) is variables assigned ByRef. You don't find the string '$gvNotAssigned =' in the following example: Global $gvNotAssigned _Assign($gvNotAssigned) Func _Assign(ByRef $var) $var = 1 EndFunc I'm just offering some thoughts on the subject. I imagine you will have considered this. Edited March 16, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
FireFox Posted March 19, 2013 Share Posted March 19, 2013 (edited) I'm trying to make a regexp to only match valid numbers. ;pattern: ;-?(\d?[.,])?\d+ ;my explanation: ;-? ;match a hypen (may not may not appear) ;(\d?[.,]) ;match any digit (may not may not appear) plus dot or comma. ;\d+ ;match any digit plus any length The problem is that it matches when I set more than one hypen, dot or comma; I have tried this pattern: "-?{1}" without any success. ;e.g : ;--0.5 ;not good ;-0..5 ;not good ;-0.5 ;ok ;0.5 ;ok ;.5 ;ok ;,555 ;ok Thanks for anyhelp. Br, FireFox. Edited March 19, 2013 by FireFox Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 19, 2013 Moderators Share Posted March 19, 2013 FireFox, This script limiting an input to valid numbers should help: #include <WindowsConstants.au3> #include <EditConstants.au3> Global $iDecimal = 2 GUICreate("Input Filter", 300, 30, -1, -1) Global $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState(@SW_SHOW) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd Func _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 StringRegExp($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]') Then $Read_Input = StringRegExpReplace($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]', '\1') $Point1 = StringInStr($Read_Input, ".", 0) $Point2 = StringInStr($Read_Input, ".", 0, 2) If $Point2 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point2 - 1) If $Point1 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point1 + $iDecimal) GUICtrlSetData($inTest, $Read_Input) EndIf EndFunc ;==>_WM_COMMAND M23 trescon 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FireFox Posted March 19, 2013 Share Posted March 19, 2013 @Melba23 Ouch. This one is very tricky, I was expecting a regexp test. Thank you anyway I will use that except if someone offers better. Br, FireFox. Link to comment Share on other sites More sharing options...
iamtheky Posted March 19, 2013 Share Posted March 19, 2013 (edited) if those are the only potential pitfalls in your usage can you just check for those and then proceed if unmatched? If stringregexp($num , "(--|\.\.|,,)") Then msgbox (0, '' , "invalid number") else Edited March 19, 2013 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
FireFox Posted March 19, 2013 Share Posted March 19, 2013 @boththose Yep why not. I will take a look at this. thanks. Br, FireFox. Link to comment Share on other sites More sharing options...
AZJIO Posted March 19, 2013 Share Posted March 19, 2013 (edited) FireFox expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> $hGui = GUICreate('Только число', 220, 180) $iInput = GUICtrlCreateInput('', 10, 10, 200, 20, -1, $WS_EX_STATICEDGE) GUISetState() GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam) Local $nNotifyCode, $nID, $sText, $iInput0 $nNotifyCode = BitShift($iwParam, 16) $nID = BitAND($iwParam, 0xFFFF) Switch $hWnd Case $hGui Switch $nID Case $iInput Switch $nNotifyCode Case $EN_CHANGE $iInput0 = GUICtrlRead($iInput) ; $sText = StringRegExp($iInput0, '(\d+(\.(\d+)?)?)', 2) ; $sText = StringRegExp($iInput0, '(-?(\d+([.,](\d+)?)?)?)', 2) $sText = StringRegExp($iInput0, '([.,](\d+)?)|(-?(\d+([.,](\d+)?)?)?)', 2) If @error Then GUICtrlSetData($iInput, '') Else If $iInput0 <> $sText[0] Then GUICtrlSetData($iInput, $sText[0]) EndIf EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Edited March 19, 2013 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
FireFox Posted March 19, 2013 Share Posted March 19, 2013 (edited) @AZJIO Great ! I wasn't so far Thanks Br, FireFox. Edited March 19, 2013 by FireFox Link to comment Share on other sites More sharing options...
PhoenixXL Posted March 20, 2013 Author Share Posted March 20, 2013 (edited) The WM_COMMAND code is borrowed from that of AZJIOThe regex code is easy. You can easily decode it. If you are not aware then look for LookBehind hereSupportsInternational number system that is three numbers after which there should be a comma.The number cannot have comma succeeding a decimalThere should be three numbers before the decimal, with the exception if the number has no comma or is starting with a decimal.The start could either be by a "-" or "digit" or "." or ","I was just wondering if you needed a delemiter support[like SPACE] so that it could support multiple numbers ?Hope it fits your requirement. Please mention if something has to be modified#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> $hGui = GUICreate('?????? ?????', 220, 180) $iInput = GUICtrlCreateInput('', 10, 10, 200, 20, -1, $WS_EX_STATICEDGE) GUISetState() GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam) If $ilParam <> GUICtrlGetHandle($iInput) Then Return $GUI_RUNDEFMSG Local $nNotifyCode, $nID, $sText $nNotifyCode = BitShift($iwParam, 16) Static $spText = '' Switch $nNotifyCode Case $EN_CHANGE $sText = GUICtrlRead($iInput) If Not StringRegExp($sText, '^(-)?(\d*\.\d*|(\d{1,3}|^)(?:,\d{0,3})+(?:(?<=\d{3})\.\d*)?|\d*)$') Then GUICtrlSetData($iInput, $spText) Else $spText = $sText EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDRegards Edited March 20, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 20, 2013 Moderators Share Posted March 20, 2013 PhoenixXL, Very nice. I have been trying (and failing ) to incorporate a limit to the digits permitted after the decimal point. I am thinking of currency values where there can be only 2 or 3 "pence/cents" digits. Any chance you can put me out of my misery? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PhoenixXL Posted March 20, 2013 Author Share Posted March 20, 2013 @M23 Here we go#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> $iMaxDecimalCount = 2;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Here it is $hGui = GUICreate('?????? ?????', 220, 180) $iInput = GUICtrlCreateInput('', 10, 10, 200, 20, -1, $WS_EX_STATICEDGE) GUISetState() GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam) If $ilParam <> GUICtrlGetHandle($iInput) Then Return $GUI_RUNDEFMSG Local $nNotifyCode, $nID, $sText $nNotifyCode = BitShift($iwParam, 16) Static $spText = '' Switch $nNotifyCode Case $EN_CHANGE $sText = GUICtrlRead($iInput) If Not StringRegExp($sText, '^(-)?(\d*\.\d{0,' & $iMaxDecimalCount & '}|(\d{1,3}|^)(?:,\d{0,3})+(?:(?<=\d{3})\.\d{0,' & $iMaxDecimalCount & '})?|\d*)$') Then GUICtrlSetData($iInput, $spText) Else $spText = $sText EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDRegards My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 20, 2013 Moderators Share Posted March 20, 2013 PhoenixXL, Thanks. I can see where I was going wrong now - close but no cigar. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FireFox Posted March 20, 2013 Share Posted March 20, 2013 (edited) @PhoenixXLThank you for your example, however this is a special input that does not match international number system.I'm back for another regexp :I would like to match any variable name declared in a script, this is what I've tried so far :#include <Array.au3> $s = "Local $toto = 'toto', $tata = 'tata' _" & @CrLf & @TAB & @TAB & "$titi = 'titi', $tutu = 'tutu'" $a = StringRegExp($s, "(?s)(?:Local|Global)(\s?\$\w+)(,\s?\$\w+)", 3) _ArrayDisplay($a) ;success output : ;[0] = $toto ;[1] = $tata ;[2] = $titi ;[3] = $tutuAs PhoenixXL said to me, it's not possible to match two things and I don't know if it's the case here to match a variable name after the declaration scope and the variables after each comma.This pattern is not complete as it should match splitted lines, the tab characters may not appear depending on the tidy.I promise, when I will have some time to spare I will learn the regexp thanks to your links Edited March 20, 2013 by FireFox Link to comment Share on other sites More sharing options...
AZJIO Posted March 20, 2013 Share Posted March 20, 2013 FireFox,Yesterday I tried to solve a similar problemThe number of variables is unknown. If you make a loop in the SRE, then it returns the last group. You need two SRE. The first cuts the content area with variables. The second looks for variables in a specified area My other projects or all Link to comment Share on other sites More sharing options...
FireFox Posted March 20, 2013 Share Posted March 20, 2013 @AZJIO I have tried the patterns from your link but they are not working for my test var. To be honest I'm lost with what you said. Link to comment Share on other sites More sharing options...
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