Jump to content
Sign in to follow this  
litlmike

Possible Bug? Or Am I Stupid?

Bug or Stupid?  

10 members have voted

  1. 1. Report it?

    • Its a Bug in AutoIt, report it!
      0
    • Not A Bug, litlmike is stupid
      9
    • Might be a Bug, report it
      1


Recommended Posts

litlmike

I just noticed something that gave me quite a bit of trouble, and I need you programming gods to let me know if this is a Bug I should report, or am I just a moron.

The issue:

Script works in 1 syntax, but not the other. Can you tell me why?

Syntax that works:

$vTerm_Search = "AutoIt"
    $Table1 = Find_Table_in_Browser ($oIE, $vTerm_Search)oÝ÷ Ù,§µ¬m«]¡ë'¢Ü(®F®¶­s`b33cµF&ÆSÒfæEõF&ÆUöåô'&÷w6W"b33c¶ôRÂb33c·eFW&Õõ6V&6ÒgV÷C´WFôBgV÷C²oÝ÷ ØÚ®º+jëh×6#include <IE.au3>

Global $vTerm_Search
Main ()

Func Main ()
    $oIE = _IE_Example ("table")
    $vTerm_Search = "AutoIt"
    $Table1 = Find_Table_in_Browser ($oIE, $vTerm_Search)
EndFunc;<==Main


Func Find_Table_in_Browser ($oIE, $iEnd)
    ;Get TableData i.e. like a List of Usernames
    $iCC = 0
    Do
        $oTable = _IETableGetCollection ($oIE, $iCC)
        $aTableData = _IETableWriteToArray ($oTable)
            If @error Then 
                ConsoleWriteError (@CRLF & "Error = " & @error & @CRLF)
                Exit
            EndIf
        ConsoleWrite (@CRLF & "$iCC = " & $iCC & @CRLF & "$aTableData[0][0] = " & $aTableData[0][0] & @CRLF)
        $iCC+=1
    Until $aTableData[0][0] = $iEnd

EndFunc;<==Find_Table_in_Browser()oÝ÷ Ùh¥*Þj×®º+jëh×6#include <IE.au3>

Global $vTerm_Search
Main ()

Func Main ()
    $oIE = _IE_Example ("table")
    $Table1 = Find_Table_in_Browser ($oIE, $vTerm_Search = "AutoIt")
    
EndFunc;<==Main


Func Find_Table_in_Browser ($oIE, $iEnd)
    ;Get TableData i.e. like a List of Usernames
    $iCC = 0
    Do
        $oTable = _IETableGetCollection ($oIE, $iCC)
        $aTableData = _IETableWriteToArray ($oTable)
            If @error Then 
                ConsoleWriteError (@CRLF & "Error = " & @error & @CRLF)
                Exit
            EndIf
        ConsoleWrite (@CRLF & "$iCC = " & $iCC & @CRLF & "$aTableData[0][0] = " & $aTableData[0][0] & @CRLF)
        $iCC+=1
    Until $aTableData[0][0] = $iEnd

EndFunc;<==Find_Table_in_Browser()
Edited by litlmike

Share this post


Link to post
Share on other sites
theguy0000

I chose the second option.

It's not

$Table1 = Find_Table_in_Browser ($oIE, $vTerm_Search = "AutoIt")

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites
martin

I just noticed something that gave me quite a bit of trouble, and I need you programming gods to let me know if this is a Bug I should report, or am I just a moron.

The issue:

Script works in 1 syntax, but not the other. Can you tell me why?

Syntax that works:

$vTerm_Search = "AutoIt"
    $Table1 = Find_Table_in_Browser ($oIE, $vTerm_Search)oÝ÷ Ù,§µ¬m«]¡ë'¢Ü(®F®¶­s`b33cµF&ÆSÒfæEõF&ÆUöåô'&÷w6W"b33c¶ôRÂb33c·eFW&Õõ6V&6ÒgV÷C´WFôBgV÷C²
As far as the part of your post copied above then

$Table1 = Find_Table_in_Browser ($oIE, $vTerm_Search);passes the value of $vTerm_Search as a parameter.

BUT, I think unlike it would in C for example, this

$Table1 = Find_Table_in_Browser ($oIE, $vTerm_Search = "AutoIt"); evaluates ($vTerm_Search = "AutoIt") as a boolean expression, as in

if $vTerm_Search = "Autoit", so the parameter passed is either true or false and not the variable value.

In C the test for equality and setting of a value are distict because you use == for one and = for the other, or in DElphi you use := and =, but in Autoit and most basic-like languages there is only = for either case and it can cause this type of problem.

Edit:spelling

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
BrettF

Really, the only time you use that type of syntax (the one that wasn't working) is because its a default option in a function. Like this:

Func _MyTestFunc ($oIE, $vtermsearch = "AutoIt")
msgbox (0, "Showing this function", "IE Object is: "& $oIE & @CRLF &"Search term is: " & $vtermsearch)
EndFunc  
oÝ÷ Ù*-ê)*'¶­Ê¡iÜ(®H§×ªÞ²Ø^½ªâi¹^mçè­ên¶Ø§+bØ^~éܶ*'b­®'¶^rV«y«Ú®&ì!z|¨¹Æ¥çmçîËb¢p'¢z£*.r¥v붬¶ »-4ÓMý³²jëh×6$Table1 = Find_Table_in_Browser ($oIE, "AutoIt")

Or change the function to have what i described above.

Hope that helps :shocked:

Share this post


Link to post
Share on other sites
martin

Really, the only time you use that type of syntax (the one that wasn't working) is because its a default option in a function.

I disagree with you; it is perfectly valid to pass a parameter using $variable = $someotherVariable provided you know what is happening. As I said in my post, in Autoit this would be passing a boolean, and this is exactly what I do in some of my scripts, but in C it would pass the variable value which might or might not be boolean.

Setting $variable = "something" is not declaring the variable.

The fact that default parameters are set this way makes the mistake perfectly understandable.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
BrettF

@martin- Ok. I can see where you're coming from. Maybe i should have been a little clearer.

I disagree with you; it is perfectly valid to pass a parameter using $variable = $someotherVariable

When did I say I was making one variable another variable? When was I setting the data of one, with the value of another?

Let me rephrase my first line to make it clearer:

Really, the only time you would use $var = "String" is when you are creating a function. Not when you call the function.

Setting $variable = "something" is not declaring the variable.

Ok. I mucked up my words there. The correct term would have been define. Where I said:

declares the variable before putting it in the function.

I was wrong. I'll admit that. It should have been:

defines the value of variable before putting it in the function.

Happy now?

As I said in my post, in Autoit this would be passing a boolean, and this is exactly what I do in some of my scripts, but in C it would pass the variable value which might or might not be boolean.

I don't fully understand booleans. I'm still learning them. I have a basic understanding of them in AutoIt, but not a full understanding. Correct me if I'm wrong.

This is from the Help File:

Booleans are logical values. Only two Boolean values exist: true and false.

They can be used in variable assignments, together with the Boolean operators and, or and not.

If Boolean values are used together with numbers, the following rules apply:

A value 0 will be equal to Boolean false

Any other number value will be equal to Boolean true

If you use strings together with Boolean values, they will be converted as follows:

A Boolean true will be the string value "True"

A Boolean false will be the string value "False"

The other way around however is different. When you use string comparisons with Boolean values, the following rules apply:

Only an empty string ("") will be a Boolean false

Any other string values (including a string equal "0") will be a Boolean true

So where were we using booleans? I'm not sure where there was a variable with a value of true of false? A variable with a value of 0 or 1? I'm having trouble understanding that. And this is AutoIt, not C. I haven't bothered to learn C. I don't need to, and at this moment in time, I don't need to. I'm happy with AutoIt and the way it is.

The fact that default parameters are set this way makes the mistake perfectly understandable.

Glad to see you understand something.

Thankyou,

Share this post


Link to post
Share on other sites
BrettF

you leave us no other choice than #2 litlmike :shocked:

:( Sorry for 1/2 hijacking your thread BTW, litlmike. You should put in an option up the top like. I didn't have the right syntax, or I didn't understand it properly rather than calling yourself stupid :P

Share this post


Link to post
Share on other sites
martin

@martin- Ok. I can see where you're coming from. Maybe i should have been a little clearer.

When did I say I was making one variable another variable? When was I setting the data of one, with the value of another?

You didn't. I only used the example of setting one varaible equal to another to make it more general.

Let me rephrase my first line to make it clearer:

Ok. I mucked up my words there. The correct term would have been define. Where I said:

I was wrong. I'll admit that. It should have been:

Happy now?

Don't worry so much, I wasn't unhappy in the first place. I just disagreed and discussed what I thought. It was not my intention to irritate anybody perhaps I was being a little pedantic.

I don't fully understand booleans. I'm still learning them. I have a basic understanding of them in AutoIt, but not a full understanding.

A boolean can result from a comparison even though the items being compared are not boolean themselves. Here is an example of what I was trying to say out in my first post. Maybe this helps.

CODE

$s1 = 'England'

$s2 = 'Australia'

testit($s1,$s2,$s1 = 'pom');here $s1 is not being set to be 'pom' although it looks like it is.

;It is being compared and the statement $s1 equals 'pom' is a false statement.

;(Obviously I have chosen a bad example, but you see what I mean I hope.)

testit($s1,$s2,$s1 <> $s2);so here you will find that $s1 is unchanged

Func testit($first,$second,$yesno)

msgbox(0,'values passed are',$first & ', ' & $second & ', ' & $yesno)

EndFunc


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
BrettF

perhaps I was being a little pedantic.

As was I.... Thanks for your example too..... It dose fulfill my lost understanding for them. :shocked: I'm sorry if I offended you :(

Share this post


Link to post
Share on other sites
Uten

I'll give it to you @litlmike, putting up a poll like that..:(

It's not a bug. It's, as explained by others, how the language works (or should I say evaluates arguments used in a function call).

Nice sample you provided, so your probably not so stupid after all..:shocked:

Share this post


Link to post
Share on other sites
litlmike

It is unanimous, litlmike is stah...stah...stupid!

Thanks for everyone's help in clearing that up, I really appreciate every bit of knowledge the community passes on.

@theguy0000

it's just

$Table1 = Find_Table_in_Browser ($oIE, "AutoIt")
I thought AutoIt would laugh at me if I tried that, but thanks for clearing that up!

@martin

The fact that default parameters are set this way makes the mistake perfectly understandable.

thanks for easing the blow! lol....

@Bert

:shocked: Sorry for 1/2 hijacking your thread BTW, litlmike. You should put in an option up the top like. I didn't have the right syntax, or I didn't understand it properly rather than calling yourself stupid :(

No worries, you and martin's discussion was quite funny and educational. I thought it would be funnier (and maybe more descriptive) to use "stupid" :P

@Uten

I'll give it to you @litlmike, putting up a poll like that..:cheer:

It's not a bug. It's, as explained by others, how the language works (or should I say evaluates arguments used in a function call).

Nice sample you provided, so your probably not so stupid after all..;)

Thanks for the feedback... :sorcerer:

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
Sign in to follow this  

×