Jump to content

ConsoleWrite


JohnOne
 Share

Recommended Posts

Just wondering if this is a bug.

Local $a1[2] = [1,2]
Local $a2[2] = [1,2]

$cw = ConsoleWrite($a1 & @CRLF & $a2 & @CRLF & "some text" & @CRLF)
ConsoleWrite("error and return = " & @error & " " & $cw & @LF)

Output..

>Running:(3.3.12.0)blah...
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
error and return = 0 0
+>20:59:36 AutoIt3.exe ended.rc:0
>Exit code: 0    Time: 0.536

I understand an array might not have a value to display, there are other values in the expression that do.

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Compared to this, makes me believe it to be some sort of bug.

Local $a1[2] = [1,2]
Local $a2[3] = [1,2,3]

$cw = ConsoleWrite(null & @CRLF & $a2 & @CRLF & "some text" & @CRLF)
ConsoleWrite("error and return = " & @error & " " & $cw & @LF)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Moderators

JohnOne,

This very thing was discussed a few months ago amongst the MVPs and there was a sharp difference of opinion between those who believe that as arrays have no String return it is quite reasonable that ConsoleWrite should fail when asked to concatenate one with a string, and those who felt that the array should just be counted as an empty string and the remainder of the parameters displayed.

This was the code I posted to show what happens:

#include <array.au3>

Global $a[1] = ["Test1"], $s = "Test2"

; Attempt to concatenate array and string - you get an array
Local $x = $a & " / " & $s & " end" & @CRLF
; This CW fails completely as the argument is not a string
ConsoleWrite($x & " - " & VarGetType($x) & @CRLF)
; But the array remains untouched - you can see the array type remains
_ArrayDisplay($x, VarGetType($x))

; Reversing the order of concatenation gives a string and just ignores the array
Local $y = $s & " / " & $a & " end" & @CRLF
ConsoleWrite($y & VarGetType($y) & @CRLF)
The discussion ended without a firm decision being taken as to what should be the "correct" result - and as one who supported the first of the options I outlined above I am quite happy to retain the status quo. ;)

M23

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:

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

 

Link to comment
Share on other sites

In the example above, $a2 does appear to be treated as an empty string, consolewrite only fails when an array is first to be parsed.

That's what made me believe it to be a bug.

Local $a1[2] = [1,2]
Local $a2[3] = [1,2,3]
Local $a3[4] = [1,2,3,4]
Local $anythingelse

$cw = ConsoleWrite($a1 & @CRLF & $a2 & @CRLF & $a3 & @CRLF & "some text" & @CRLF)
ConsoleWrite("error and return = " & @error & " " & $cw & @LF)

$cw = ConsoleWrite($anythingelse & $a1 & @CRLF & $a2 & @CRLF & $a3 & @CRLF & "some text" & @CRLF)
ConsoleWrite("error and return = " & @error & " " & $cw & @LF)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

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