Muhammad_Awais_Sharif

StringIsDigit Does not work properly

9 posts in this topic




the reason is you using the == operator, which is dedicated to case-sensitive string comparison, for boolean and numeric comparison, not cool.

Share this post


Link to post
Share on other sites

okay thank you :D

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

"1" is a string, and 1 is a number, TRUE is boolean....

you should not compare a string with a number ! The result of a comparison is TRUE or FALSE

(1 = "1") is (should be) FALSE   //EDIT (but NOT in AutoIt because of datatype "variant"?! ) so (1="1") in AutoIt is TRUE

(1 = TRUE) is TRUE

Edited by AndyG

Share this post


Link to post
Share on other sites

okay :D 

problem is that in C++ or java single = operator assign value.

So that's why i was using double equal :D

i got it ty :D 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

More precisely, when you write:

If StringIsDigit($tmp) == True Then

the interpretor understands:

If '1' == 'True' Then

because == forces the conversion of its operands to strings and StringIsDigit returns the integer 0 or 1 (1 in your case), while the string 'True' stays by itself. Since the == comparison is over verbatim (case-insensitive) strings, it clearly fails.

The lazy, simple and robust way to code that condition is:

If StringIsDigit($tmp) Then
Edited by jchd
2 people like this

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

3 hours ago, jchd said:

 

The lazy, simple and robust way to code that condition is:

If StringIsDigit($tmp) Then
 
 
 
 

Indeed!

@Muhammad_Awais_Sharif  ...Use a single equals (=) for comarison, as well as assignment in AutoIt for cases like this...or just say "If X Then" (whenever X is true..."Then" will execute)

(...It took me a few minutes to wrap my head around the 'single equals comparison' as well, so you're in good company!) :)

bloopie

Edited by bloopie
clarification
1 person likes this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • tcox8
      By tcox8
      Hello,
      Currently I am running a script that calls a powershell script. To read the results of that I am reading StdOut. I am parsing things accordingly but unfortunately it doesn't parse correctly all the time and I end up missing parts of the string or other problems. My question then is, what is the best results for reading what is returned when running a powershell script or something similar?
    • Valnurat
      By Valnurat
      I hope my title is good enough.
      I'm using the ADO UDF and I have question regarding editing SQL records with this UDF.
      The owner of the UDF suggested an idea, but maybe there is another trix.
    • Valnurat
      By Valnurat
      I have a SQL db. I would like to view the content in a control. Like a table. The control should have the option to show every 2nd line in another color. When you pick a "cell" it should pick the whole row. When you dobbelt click on the row another windows should popup with the content from the row.
      What view control can do that?
    • Valnurat
      By Valnurat
      How do I access a sql database for inserting and reading?
    • Valnurat
      By Valnurat
      I'm trying to get some info from dell.com page. I use a servicetag to find the computer. From the computerinfo I would like to get the "Shipping Date", but the date is on the next "cell".
      I have done this and I don't know if this is correct aproach, but I do get some info out.
      I just don't know how to "jump" to the next cell.
       
      #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate("http://www.dell.com/support/home/dk/da/dkbsdt1/product-support/servicetag/gnn5f12/configuration") Local $oTds = _IETagNameGetCollection($oIE, "td") Local $sTxt = "" For $oTd In $oTds $sTxt &= $oTd.innertext & @CRLF Next MsgBox($MB_SYSTEMMODAL, "Form Input Type", " Types :" & @CRLF & $sTxt) _IEQuit($oIE) I have seen something like this in VBscript
      Cell.NextSibling.NextSibling.innertext Is there someone who could help me.