Jump to content
Sign in to follow this  
mexykanu

The if function does not see arrays or objects as being true , _ie.au3 variables are lost when navigating

Recommended Posts

Er...What about UBound? Seriously, the issues you have mentioned are not issues, just not reading he help file properly or understanding the language.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
1 minute ago, mexykanu said:
5 minutes ago, water said:

If you want to check the CONTENT of an array then you have to write a function for it.
Imagine the following code:

Global $aArray[2] = [True, False]
$aArray[0] = True
$aArray[1] = False

How would you evaluate the CONTENT of this array? Is it True or False?

This array would be True as it contains at least one value which is not False, empty, null, zero, whitespace.

Then you need a function like this:

Func _ArrayCheckTrue(ByRef $aArray)
    For $i = 1 to UBound($aArray) - 1
        If $aArray[$i] = True then Return True
    Next
    Return False
EndFunc

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

:offtopic:

Today I have a great winter weather. I'm going with my family on skates.
I will return in the evening ...
Regards

mLipok

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

Have fun :brr:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites
23 minutes ago, water said:

Arrays are covered in the help file but you should have a look at the wiki as well. There is a tutorial that describes arrays in depth.

Hello,

I could not find the Help file section for arrays, could you please point me to it?

I Also could not find in the Help file, in the section for the "if " function, the Remark that tells the programmer that " The "if" function does not currently evaluate arrays or objects as True or False and that the programmer should :

a ) create his own function for testing arrays

b ) use IsObj for testing objects

 

So until now we have concluded that a bug is "something doesn't work as documented in the help file".

And that:

1. The Help description and/or functionality of the _IETagNameGetCollection and _IETagNameGetAllCollection are incomplete

2. There is no information regarding arrays functionality in the Help file, or at least i could not find it by typing "Array" and there is also no information in "Datatypes"

3. There is no information regarding the datatypes evaluated by the "If" function. There is no information regarding how the "If" function evaluates expressions.

 

I can accept that i was wrong about IsObj() and that i do not know how to use AutoIt correctly. But please accept that there are issues with AutoIt and fix them, so that other programmers would not have to encounter the same issues. I am sure i'm not the only one that encountered them until now. Even if the issues are related to the Help file, they're equally as important as the programming language itself.

Thank you.

 

Share this post


Link to post
Share on other sites
3 minutes ago, mexykanu said:

I could not find the Help file section for arrays, could you please point me to it?

You are serious?
Press F1 in SciTE, select the search tab and enter "Array". Voilá!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites
6 minutes ago, water said:

You are serious?
Press F1 in SciTE, select the search tab and enter "Array". Voilá!

Dear sir, there is no specific section for arrays in the "Datatypes" help file. My point is valid

Why is it so hard to make you guys understand what i'm saying ?

Why is it hard to accept that the Help file needs improvements ?

3 minutes ago, czardas said:

:frantics:

Local $vVar
If Not IsArray($vVar) Then MsgBox(0, "", 'DUH!')

 

Thank you for your reply, unfortunately this has already been discussed. Please read the whole topic.

Share this post


Link to post
Share on other sites

mexykanu,

If <X> ... converts <X> to a boolean. There is currently no provision in AutoIt to convert an array into a boolean, since that conversion doesn't make any sense. YOU want the operation to mean that if any element of the array contains True, then the result should be True, but every other programmer except YOU will most probably attach a completely different semantics to such an operation. No language that I know of allows such operation either.

Conversion from basic datatypes to boolean is covered in the help. Conversions not explicitely specified should be considered illegal or at least meaningless.

There isn't the faintest level of bug in all you "report". Also when asking for help, it's common to avoid a superioir tone like yours.


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

Why do you insist that arrays have to be described in the Datatypes section? What DATA-type is an array? An array is a type of variable and CONTAINS data.
This means you have to check the Variables section of the help file.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites
12 minutes ago, jchd said:

mexykanu,

If <X> ... converts <X> to a boolean. There is currently no provision in AutoIt to convert an array into a boolean, since that conversion doesn't make any sense. YOU want the operation to mean that if any element of the array contains True, then the result should be True, but every other programmer except YOU will most probably attach a completely different semantics to such an operation. No language that I know of allows such operation either.

Conversion from basic datatypes to boolean is covered in the help. Conversions not explicitely specified should be considered illegal or at least meaningless.

There isn't the faintest level of bug in all you "report". Also when asking for help, it's common to avoid a superioir tone like yours.

Hello,

I apologize if a superior tone results from what i'm writing. This is merely frustration. I have the highest respect for AutoIt, its developers, its community and this is why i want it to be improved.

Back to topic:

This explanation is excellent and should be included in the Help file. If i would have received this answer in the first place, then this topic would only have two posts.

Regarding "No language that I know of allows such operation either" - PHP and Javascript allow this operation for both array and objects, it is extremely helpful and, at least for me, it does not generate confusion.

 

Quote

Why do you insist that arrays have to be described in the Datatypes section? What DATA-typw is an array? An array is a type of variable and CONTAINS data.
This means you have to check the Variables section of the help file.

YES! This is exactly what i was talking about. Because arrays contain datatypes, i wrongly expected arrays to be referenced in datatypes. As i said above, i accept when i'm wrong and this is certainly a case in which i was wrong. Thank you for pointing out the Variables section.

 

Nevertheless, the mentioned issues still stand:

1. The Help description and/or functionality of the _IETagNameGetCollection and _IETagNameGetAllCollection are incomplete

2. The documentation for the "If" function should be improved and jchd's post would make a great addition.

Thank you.

 

 

Edited by mexykanu

Share this post


Link to post
Share on other sites
28 minutes ago, mexykanu said:

Please read the whole topic.

Topic seems to be going round in circles. I read it just over an hour ago and must have missed this. As jchd said, it's meaningless to convert an array to True or False anyway.

Is this array True or False?

Local $aArray[0]

 

Edited by czardas

Share this post


Link to post
Share on other sites

mexykanu,
You have been around since 2007. I wonder why such basic AutoIt concepts like Arrays or the help file still seem to be new to you :huh:
To avoid further discussions of this kind I suggest to have a good reading of the help file and the tutorials in the wiki :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites
Quote

 

You have been around since 2007. I wonder why such basic AutoIt concepts like Arrays or the help file still seem to be new to you :huh:
To avoid further discussions of this kind I suggest to have a good reading of the help file and the tutorials in the wiki :)

 

Hello,

As i said earlier, i am fairly new to this language. I have started in 2007, it was the first programming language i've touched, used it for about 6 months , took a 6 year pause and then restarted learning. I do not constantly use AutoIt.

I am aware of the Help file, it probably is the best Help file for any programming language and i'm not the only one saying it. I use it regularly and i depend heavily on it. This is why i consider that the above mentioned points should be improved. I see no reason whatsoever not to improve the help file, as every piece of information is valuable.

I do not expect all programming languages to behave the same way, but i do expect functions within a programming language to have consistent behavior. If the author did not want the function to have consistent behavior while using different datatypes, then this should be mentioned in the Help file Remarks section.

 

Share this post


Link to post
Share on other sites

The help file is constantly improved. There even is a thread to suggest changes. And I talk about "full changes", means users should provide full text they want to see in the help file.

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

There are some inconsistencies in the way AutoIt operates, but bear in mind that it is a culmination of work from several different developers over a period of years. There have been some big changes and the desire to improve the language has never waned. Many changes will have a knock on effect, and this also need to be taken into consideration before making changes. 

Edited by czardas

Share this post


Link to post
Share on other sites
Quote

There are some inconsistencies in the way AutoIt operates, but bear in mind that it is a culmination of work from several different developers over a period of years. There have been some big changes and the desire to improve the language has never waned. Many changes will have a knock on effect, and these also need to be born in mind when making such changes. 

Thank you for this quality explanation.

Quote

The help file is constantly improved. There even is a thread to suggest changes. And I talk about "full changes", means users should provide full text they want to see in the help file.

Alright, in this case i will submit two issues in Trac regarding Documentation and this should be the end of this topic, unless someone else wants to add something else.

 

I would like to thank everyone in this topic for giving explanations and sharing information.

I have also changed the title of this topic to be more search friendly.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...