Jump to content

Recommended Posts

Posted

Hello,

I recently upgraded from 3.3.8.1 to 3.3.14.2 and noticed something that doesn't make sense to me:

I'm using a script to fetch records from an MSSQL Database. Some fields are empty (which is correct) and using 3.3.8.1 this works fine and sets $var2 to "something"

If ($var = "") Then
    $var2 = "something"
EndIf

After upgrading to 3.3.14.2 this doesn't work anymore. The String has a length of zero (which is the way I use now as a workaround)

If (StringLen($var) = 0) Then
    $var2 = "something"
EndIf

But I don't understand why this won't work anymore. Any Idea?

Thanks!

Posted

Both work for me:

Local $var = ""

If (StringLen($var) = 0) Then
    MsgBox(0, 1, "Works")
EndIf

If ($var = "") Then
    MsgBox(0, 2, "Works")
EndIf

I think something is wrong in your code... did you check for script breaking changes?

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted

Yes I did. I didn't notice anyhting regarding my problem.

But declaring the var with "" as in your example should work in any case - since then it is indeed '""'. Even with a new script and just declaring Dim $var (without = "") works.

In my case it's part of an array that comes back from am MSSQL query. This returns NULL - and it seems that this was handled in a different way? I tested my code on an old 3.3.8.1 installation and the same code (without StringLen) works perfectly. Strange?!

Posted

Indeed

$var = String($var)

works fine with = ""

Did I miss something in the changelog? Or was is just a guess? Anyway, thanks a lot - I'll do a bit of code-rework now back to = "" with the String statement :)

Posted (edited)

Null.....

You get null from SQL. 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 1/25/2016 at 9:55 AM, mLipok said:

Null.....

You get null from SQL. 

Expand  

Yes, I get null from SQL - that didn't change between AutoIT Versions and is still the same. But testing for null did change as it seems. In 3.3.8.1. a test for null works fine with just = "" - apparently this changed in new versions where you have to take a look at StringLen or String($var). That was my problem...

Posted
  On 1/25/2016 at 10:30 AM, AIstarter said:

But testing for null did change as it seems. In 3.3.8.1. a test for null works fine with just = "" - apparently this changed in new versions where you have to take a look at StringLen or String($var). That was my problem...

Expand  

 

https://www.autoitscript.com/autoit3/docs/autoit_changelog.txt
3.3.10.0 (23rd December, 2013) (Release)
Added: Keyword Null.
 

You should check like this:
 

If $var = Null or $var = "" then
...
EndIf

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...