Jump to content

Recommended Posts

Posted

Wow, that's quite a list Thanks Jon, trancexx and to all others who have contributed. I must admit I can't imagine why they call it a ternary operator. Ah well, it's not important. Thanks again!

Posted (edited)
  On 7/10/2013 at 9:04 AM, James said:

Ternary comes from mathematics, n-ary. FYI, Ternary is also known as Tertiary :)

 

I know the mathematical use of the terms. Like I said it's not important. It's a nice feature regardless! :)

Edit

I think you meant trinary, not tertiary. Anyway I just read up on it a bit:

  Quote

Although many ternary operators are possible, the conditional operator is so common, and other ternary operators so rare, that the conditional operator is commonly (albeit incorrectly) referred to as the ternary operator.

 

Link

Edited by czardas
  • Moderators
Posted (edited)

Hi,

For those who might be wondering how some of the new features work, here is some code which should help explain:

#AutoIt3Wrapper_Run_AU3Check=n

#include <Constants.au3>

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; Ternary operator
MsgBox($MB_OK, "Result: 1=1", (1 = 1) ? "True!" : "False!")
MsgBox($MB_OK, "Result: 1=2", (1 = 2) ? "True!" : "False!")

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; Array dereferencing
Global $sString = "0-1-2-3-4"
MsgBox($MB_OK, "Array Deref", StringSplit($sString, "-")[3]) ; Display the 3rd element of the split array

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; Non-explicit array bound definition
Global $aArray[] = [0, 1, 2, 3, 4] ; Note declared with no bounds, but with elements
MsgBox($MB_OK, "Result", $aArray[2])

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; Functions as first class objects

; Using native functions
$Func = MsgBox
$Func(0, "Native", "Hello World!")

; Using UDFs
$Func = _UDF_Func_1
$Func(0, "UDF", "Hello World!")

Func _UDF_Func_1($v1, $v2, $v3)
    Return MsgBox($v1, $v2, $v3)
EndFunc

; UDF function return
$Func = _UDF_Func_2()
$Func($MB_OK, "UDF-Func-Return-1", "Hello World!")

$Func = _UDF_Func_2()(0, "UDF-Func-Return-2", "Hello World!")

Func _UDF_Func_2()
    Return MsgBox
EndFunc

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; ByRef parameters in Call
Local Enum $eParam_1, $eParam_2, $eParam_3
$sByRefCall = "Before Call"
Call('_Called_Func', $eParam_1, $eParam_2, $eParam_3, $sByRefCall)
MsgBox($MB_OK, "After Call", $eParam_1 & @CRLF & $eParam_2 & @CRLF & $eParam_3 & @CRLF & $sByRefCall)

Func _Called_Func($vParam_1, $vParam_2, $vParam_3, ByRef $sString)
    MsgBox($MB_OK, " In Function", $vParam_1 & @CRLF & $vParam_2 & @CRLF & $vParam_3 & @CRLF & $sString)
    $sString = "After Call"
EndFunc
I have added the line to disable AU3Check as this is obviously still a bit behind the core code - Jon has to decide the final syntax for some of the features before they can be correctly checked. ;)

 

M23

Edited by Melba23
Ternary examples amended to be less "terrible"

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

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Administrators
Posted

Hmm, it hadn't been typed into the changelog, but there were some significant changes to Aut2Exe/compiling as well. Scripts are stored as a normal resource rather than hacked onto the end of the exe.

Look in the helpfile for directives/#pragma options which allow you to control aspects of the compiled exe like icons/versions/UAC options. Most of this was available in the scite editor/autoitwrapper scripts but it's nice to have it self contained in the main compiler.

Posted
  On 7/10/2013 at 9:53 AM, Jon said:

Hmm, it hadn't been typed into the changelog, but there were some significant changes to Aut2Exe/compiling as well. Scripts are stored as a normal resource rather than hacked onto the end of the exe.

Look in the helpfile for directives/#pragma options which allow you to control aspects of the compiled exe like icons/versions/UAC options. Most of this was available in the scite editor/autoitwrapper scripts but it's nice to have it self contained in the main compiler.

I think that was trancexx too, she did some thing with it for some reason that I can't remember now.

Posted

ByRef in Call: This does not work with CallArgArray, elements will not be changed.

For the new functions as first class objects, here is an example of possible usage, that might actually be useful.

_EnumFolder("C:\", MyCallback)

Func MyCallback($sFile)
    ConsoleWrite($sFile & @LF)
EndFunc   ;==>MyCallback


Func _EnumFolder($sPath, $Callback)
    If StringRight($sPath, 1) <> '\' Then $sPath &= '\'

    Local $hFind = FileFindFirstFile($sPath & "*.*")
    If $hFind < 0 Then Return SetError(1)

    Local $sFile
    While 1
        $sFile = FileFindNextFile($hFind)
        If @error Then ExitLoop

        $Callback($sFile)
    WEnd

    FileClose($hFind)
EndFunc   ;==>_EnumFolder

This does not create an empty array:

Local $a = []
ConsoleWrite(UBound($a) & @LF)

This does:

Local $a[0]
ConsoleWrite(UBound($a) & @LF)

Currently _ArrayAdd works with empty arrays, but _ArrayDelete probably needs to be modified to allow returning of empty arrays rather than a string.

And finally: Whatever you do, do not use the new conditional operator like the changelog does to return True or False.

Posted

Quick update note on one of the mentioned items:

  Quote

- Removed #2172: Select...EndSelect statement and replaced with an If...EndIf as well as optimised the code.

This refers only to the _StringRepeat function , Select...EndSelect haven't been removed from the language.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted
  On 7/10/2013 at 11:47 AM, BrewManNH said:

Quick update note on one of the mentioned items:

This refers only to the _StringRepeat function , Select...EndSelect haven't been removed from the language.

Fixed.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted
  On 7/10/2013 at 12:31 PM, guinness said:

Fixed.

??? What's fixed?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)
  On 7/10/2013 at 12:33 PM, BrewManNH said:

??? What's fixed?

I edited the changelog since I can do that.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Is there an advantage of using Select over If?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

I think AutoIt3_x64.exe is broken in this build. I get an 'Unable to open the script file.' when dbl clicking the exe, and 'AutoIt Error (0) : ==> Unable to open the script file.' from SciTE. Can anyone confirm?

Posted (edited)

Thanks! Not sure if it's related, but compiled EXEs work (32-bit and 64-bit) but lack icons and any version etc info.

Edited by wraithdu
Posted

I personally prefer the blank icon.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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