Confuzzed

Equal strings not equal?

14 posts in this topic

Please forgive me.  I'm sure I'm doing something stupid, but here is what I am seeing.

This code snippet:

    ;$artist="Deee-Lite"
    ;$artisthold = "Deee-Lite"
    
    $temp = "$artist: " & $artist & " Type:" & VarGetType($artist) & "  Length: " & stringlen($artist) & "  "
    for $k = 1 to stringlen($artist)
        $temp = $temp & string(asc(stringmid($artist,$k,1))) & " "
    next
    logwriteline($temp)
    
    $temp2 = "$arthld: " &  $ArtistHold & " Type:" & VarGetType($artisthold) & "  Length: " & stringlen($artisthold) & "  "
    for $k = 1 to stringlen($ArtistHold)
        $temp2 = $temp2 & string(asc(stringmid($ArtistHold,$k,1))) & " "
    next
    logwriteline($temp2)
    
    if $artist <> $ArtistHold then
        logwriteline("  not equal")
    endif

...

Func LogWriteLine($value)
     FileWriteLine($logfile, $value )
EndFunc

 

Produces this output:

$artist: Deee-Lite Type:String  Length: 9  68 101 101 101 45 76 105 116 101 
$arthld: Deee-Lite Type:String  Length: 9  68 101 101 101 45 76 105 116 101 
  not equal

 

I've no idea why the two strings are not equal.  Can someone help me?

 

(Interestingly, if I un-remark the two assignment lines, it works....)

Share this post


Link to post
Share on other sites



Confuzzed,

Welcome to the AutoIt forums.

From where do you get the $artist & $artisthold variables when you run the script without the direct assignment lines?

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Confuzzed,

Welcome to the AutoIt forums.

From where do you get the $artist & $artisthold variables when you run the script without the direct assignment lines?

M23

 

Artist is assigned:  $artist:

$Array3 = StringRegExp($line2, '  Artist +(.+)', 3)
            if @error <> 1 then
                $artist = $Array3[0]
                continueloop ;handle multiple tags
            endif

Artisthold is returned from a function.  $artisthold:

$ArtistHold = ArtistFromRelease($releaseid)

...

Func ArtistFromRelease($Release2)

...

    $ArtistRead = ""

...
            $Array6 = StringRegExp($line6, 'Release by(?:.+?)<bdi>(.+?)<\/bdi>', 3)
            if @error <> 1 then
                $ArtistRead = $array6[0]
                exitloop
            endif

...

    Return $ArtistRead
    
EndFunc

 

Thanks for your help.

 

Edited by Confuzzed

Share this post


Link to post
Share on other sites

Confuzzed,

And from where do you get $line2 & $line6? Help us to help you - we do not have any idea of what your script does or how you get the values.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Because "$arthld:" is not equal to "$artist:"

Thank you for your help.  I'm sure you are right, but as far as I can tell, $artist and $artisthold are exactly the same.  Below is the output where I display the variable contents, type and length.  Then I walk both variables one character at a time and display the ascii codes.

$artist: Deee-Lite Type:String  Length: 9  68 101 101 101 45 76 105 116 101 
$arthld: Deee-Lite Type:String  Length: 9  68 101 101 101 45 76 105 116 101

The problem does not seem to be fundamental.  Most of the time the program works fine, except for this example.

Share this post


Link to post
Share on other sites

Confuzzed,

And from where do you get $line2 & $line6? Help us to help you - we do not have any idea of what your script does or how you get the values.

M23

Sorry.  I was hoping to find some way to see why the two variables are not equal...

 

Here are the contents of those two variables:

$Line2:

Artist                             Deee-Lite

 

 

$Line6: 

Release by <a href="https://url/artist/83d401e8-3322-4491-98d3-ec3a567c5047" title="Deee‐Lite"><bdi>Deee‐Lite</bdi></a>

 

Share this post


Link to post
Share on other sites

Use AscW() instead of Asc() to see the difference.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Confuzzed,

This is like drawing teeth. One last try: what is the original source of these strings?

As the code indicates that the strings are identical when you assign them directly, it follows that they are not when you derive them within your script. So from where do you get the basic data from which you extract the strings you compare? Is it from an mp3 tag? Some form of music database? Or somewhere else?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

 

Use AscW() instead of Asc() to see the difference.

Thank you!  That did it.  Here is the output now:

$artist: Deee-Lite Type:String  Length: 9  68 101 101 101 45 76 105 116 101 
$arthld: Deee-Lite Type:String  Length: 9  68 101 101 101 8208 76 105 116 101 
  not equal

 

Share this post


Link to post
Share on other sites

Confuzzed,

This is like drawing teeth. One last try: what is the original source of these strings?

As the code indicates that the strings are identical when you assign them directly, it follows that they are not when you derive them within your script. So from where do you get the basic data from which you extract the strings you compare? Is it from an mp3 tag? Some form of music database? Or somewhere else?

M23

Sorry. The program is long, and I was hoping to simply focus on the contents of the two variables, rather than from where their contents was assigned.

 

fwiw, line2 came from m4a tags and line6 came from a downloaded web page...

Share this post


Link to post
Share on other sites

I was gonna say that perhaps the dash is the culprit, as I've come across this before with music names. Obviously you can have ASC variants of a dash.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

I was gonna say that perhaps the dash is the culprit, as I've come across this before with music names. Obviously you can have ASC variants of a dash.

Yep I wondered about the dash also, and when I examined the file manually, my editor formatted the unicode.   I just couldn't see what was happening with ASC, (and just imagine my frustration with the ASC output.)

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

That's why I have all non standard ASC 2 characters replaced with standard, by default in many of my programs, including foreign accents etc. In my world, there is only one lower case 'a' and 'e' etc.

People have all sorts of things in ID3 Tags, so I just rewrite the lot.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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