xdp22 Posted January 23, 2011 Share Posted January 23, 2011 (edited) Hi, I need to do one thing, namely, checking whether the string contains and the number and digits, or if you suppose that we have a string - lol, the program will return 0, because the string contains only letters, let's say we have another string, for example - 123 as a program will return 0, but if we have a string, for example - lol123 a program will return 1 because it contains letters and numbers Can somebody help me? Thank you Edited January 23, 2011 by xdp22 Link to comment Share on other sites More sharing options...
jaberwacky Posted January 23, 2011 Share Posted January 23, 2011 bot? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
xdp22 Posted January 23, 2011 Author Share Posted January 23, 2011 (edited) yyy? bot mean Autoit code.. i using google translator.. sorry Edited January 23, 2011 by xdp22 Link to comment Share on other sites More sharing options...
jaberwacky Posted January 23, 2011 Share Posted January 23, 2011 Didn't you pretty much ask this same question earlier? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
xdp22 Posted January 23, 2011 Author Share Posted January 23, 2011 Nope.. read this topic and read earlier topic, earlier topic is for function StringIsDigit whan return 1 if string is only numbers, and return 0 if string is not only numbers, it's not that same, cuz StringIsDigit can't know string have letter's and numbers or only letters Link to comment Share on other sites More sharing options...
jaberwacky Posted January 23, 2011 Share Posted January 23, 2011 Look into StringIsAlNum() and/or StringIsASCII() Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
xdp22 Posted January 23, 2011 Author Share Posted January 23, 2011 I don't know how to do that really, i trying with StringRegExp but it's too hard for me ;/ Link to comment Share on other sites More sharing options...
jaberwacky Posted January 23, 2011 Share Posted January 23, 2011 It will be in the helpfile. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted January 23, 2011 Share Posted January 23, 2011 Looks like it's time to roll up your sleeves and get to work making your own UDF. Just break it down into steps: 1) If $string only contains letters then return 0 2) If $string only contains numbers then return 0 3) If $string contains both letters AND numbers then return 1 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
xdp22 Posted January 23, 2011 Author Share Posted January 23, 2011 Man nope StringIsAlNum and StringIsASCII() can't help me, ASCII is ALL on keyboard, so including abcd - xyz, and 0-9. StringIsAllNum just checking how much characters have string, not string is only 0-9 >.< Link to comment Share on other sites More sharing options...
jaberwacky Posted January 23, 2011 Share Posted January 23, 2011 Yes, you just sent that to me in a private message. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted January 23, 2011 Share Posted January 23, 2011 Well, good luck on your future programming endeavors. I and I am sure that others will be here to help you if you run into trouble, maybe. Only if you demonstate that you've exerted some effort into solving any problems that you may encounter. I bid you peace. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
xdp22 Posted January 23, 2011 Author Share Posted January 23, 2011 (edited) Looks like it's time to roll up your sleeves and get to work making your own UDF. Just break it down into steps: 1) If $string only contains letters then return 0 2) If $string only contains numbers then return 0 3) If $string contains both letters AND numbers then return 1 Ok i got that thank you 1) StringIsAlpha 2) StringIsDigit 3) Case Here is mine version if someone want $string = "lol123" $liczby = StringIsDigit($string) If $liczby = 0 Then $litery = StringIsAlpha($string) If $litery = 0 Then $result = 1 Else $result = 0 EndIf Else $result = 0 EndIf MsgBox( 0, "", $result) @Down thanks Edited January 23, 2011 by xdp22 Link to comment Share on other sites More sharing options...
Bowmore Posted January 23, 2011 Share Posted January 23, 2011 (edited) This may give you some more ideas for achieving what you want ;#include <file.au3> <=== not required MsgBox(0,"result",teststring("lol123")) Func teststring($s) Local $x = 0 If StringIsAlNum($s) Then $x += 1 If StringIsDigit($s) Then $x += 2 If StringIsInt($s) Then $x += 4 If StringIsFloat($s) Then $x += 8 Return $x EndFunc Edited January 23, 2011 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
guinness Posted January 23, 2011 Share Posted January 23, 2011 (edited) jaberwocky6669 means that if you try to show you are coding you are more likely to get help from users here, plus I suggest looking in the Help File for Functions because these are your friends $String = "78fff9" MsgBox(0, "_CheckString()", _CheckString($String) & " >> " & @error) ; It Returns an @error = 1 and -1 if nothing else matches. Func _CheckString($sString) If StringIsAlpha($sString) Or StringIsDigit($sString) Then Return 0 If StringIsAlNum($sString) Then Return 1 Return SetError(1, 1, -1) EndFunc ;==>_CheckString Also Bowmore I don't know why you need the Include File <File.au3>? Edited January 23, 2011 by guinness 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...
xdp22 Posted January 23, 2011 Author Share Posted January 23, 2011 (edited) It's already done guys, but thanks your version lot better. Edited January 23, 2011 by xdp22 Link to comment Share on other sites More sharing options...
guinness Posted January 23, 2011 Share Posted January 23, 2011 The difference between your version and our versions is that it can be called multiple times, whereas with yours it is only executed once, hence the reason why Functions can save you alot of time. 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...
Bowmore Posted January 23, 2011 Share Posted January 23, 2011 (edited) Also Bowmore I don't know why you need the Include File <File.au3>? You're correct It's not needed. I forgot to delete from the script cut this example from. Edited January 23, 2011 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook 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