litlmike Posted April 20, 2007 Share Posted April 20, 2007 (edited) 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: expandcollapse popup$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 April 20, 2007 by litlmike _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
theguy0000 Posted April 20, 2007 Share Posted April 20, 2007 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 Link to comment Share on other sites More sharing options...
martin Posted April 20, 2007 Share Posted April 20, 2007 (edited) 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 April 20, 2007 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. Link to comment Share on other sites More sharing options...
BrettF Posted April 20, 2007 Share Posted April 20, 2007 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 Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
martin Posted April 21, 2007 Share Posted April 21, 2007 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. Link to comment Share on other sites More sharing options...
BrettF Posted April 21, 2007 Share Posted April 21, 2007 @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 = $someotherVariableWhen 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 falseAny other number value will be equal to Boolean trueIf 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 falseAny other string values (including a string equal "0") will be a Boolean trueSo 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, Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
piccaso Posted April 21, 2007 Share Posted April 21, 2007 you leave us no other choice than #2 litlmike CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
BrettF Posted April 21, 2007 Share Posted April 21, 2007 you leave us no other choice than #2 litlmike 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 Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
martin Posted April 21, 2007 Share Posted April 21, 2007 @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 unchangedFunc 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. Link to comment Share on other sites More sharing options...
BrettF Posted April 21, 2007 Share Posted April 21, 2007 perhaps I was being a little pedantic.As was I.... Thanks for your example too..... It dose fulfill my lost understanding for them. I'm sorry if I offended you Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Uten Posted April 21, 2007 Share Posted April 21, 2007 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.. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
litlmike Posted April 23, 2007 Author Share Posted April 23, 2007 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 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" @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..Thanks for the feedback... _ArrayPermute()_ArrayUnique()Excel.au3 UDF 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