Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Should ConsoleWriteError() be merged with ConsoleWrite()?

STDIO STDOUT STDERR

  • Please log in to reply
18 replies to this topic

#1 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 24 February 2012 - 05:18 PM

I was thinking earlier that perhaps ConsoleWriteError() should be merged with ConsoleWrite() as a parameter. The parameter values could be as such:
  • 0 - <default> Write to STDOUT
  • 1 - Write to STDERR
While this would be a script breaking change it is a logical idea as they both write to console, just different pipes. However, would there be anything that could go horrible wrong with this change that I'm missing?

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

SafeExecute, for picking and choosing what commands you want Execute to be able to run.








#2 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 24 February 2012 - 05:22 PM

You're missing a good reason.

#3 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 6,115 posts

Posted 24 February 2012 - 05:24 PM

It's more logical not to do it.
  • shanet likes this
Yeah baby!

.
eMyvnE


#4 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 24 February 2012 - 05:34 PM

It's more logical not to do it.

You're missing a good reason.


Okay. Pro/Con List time.

Reasons TO merge them:
  • Easier to define where you want to write to console if in a script. (EG. You could set a ConsoleWrite() to write to STDERR by setting the flag to be @error so that if there was a success it would write to STDOUT and if NOT write to STDERR)
  • Less to type
  • Probably have the almost same source coding (then again I don't know as AutoIt isn't OSS)
Reasons NOT TO merge them:
  • Breaks scripts.
  • Makes devs do work, they already have enough

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

SafeExecute, for picking and choosing what commands you want Execute to be able to run.


#5 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,257 posts

Posted 24 February 2012 - 06:26 PM

Easier to define where you want to write to console if in a script. (EG. You could set a ConsoleWrite() to write to STDERR by setting the flag to be @error so that if there was a success it would write to STDOUT and if NOT write to STDERR)

Set the flag to be @error huh? So when it works, it prints an error message on the standard pipe instead of the error pipe? Genius.

Makes devs do work, they already have enough

Not saying I want the AutoIt developers to do more work, but isn't that the whole point of being a developer?

#6 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 24 February 2012 - 08:30 PM

ImNotVeryCleverOrICouldHaveThoughtUpThisOnMyOwn("This goes to stdout." & @CRLF) SetError(1)    ; Force an error value. ImNotVeryCleverOrICouldHaveThoughtUpThisOnMyOwn("This goes to stderr." & @CRLF) Func ImNotVeryCleverOrICouldHaveThoughtUpThisOnMyOwn($sMsg, $iError = @error)     If $iError Then         ConsoleWriteError("STDERR: " & $sMsg)     Else         ConsoleWrite("STDOUT: " & $sMsg)     EndIf EndFunc

30 seconds.
  • James and shanet like this

#7 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 28 February 2012 - 12:59 PM

Set the flag to be @error huh? So when it works, it prints an error message on the standard pipe instead of the error pipe? Genius.

You know what I mean.
PS: What the heck with the forums. I code enough HTML, I don't want to do it on here :|

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

SafeExecute, for picking and choosing what commands you want Execute to be able to run.


#8 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,257 posts

Posted 28 February 2012 - 02:49 PM

Set the flag to be @error huh? So when it works, it prints an error message on the standard pipe instead of the error pipe? Genius.

You know what I mean.
PS: What the heck with the forums. I code enough HTML, I don't want to do it on here :|

If what I said isn't what you meant, then what did you mean? If you are setting the flag to error, what I described is exactly what will happen.

#9 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 28 February 2012 - 08:14 PM

If what I said isn't what you meant, then what did you mean? If you are setting the flag to error, what I described is exactly what will happen.

Somerandomfunc("blah") ConsoleWrite("blah", @error)


I mean that if it is successful write to STDOUT, if not write to STDERR.

Ignoring the fact that I said

The parameter values could be as such:

because I said they COULD be as such not WOULD be OR just have the @error code negated in the ConsoleWrite code. I hate explaining the obvious but then again I should have been more clear.

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

SafeExecute, for picking and choosing what commands you want Execute to be able to run.


#10 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,257 posts

Posted 28 February 2012 - 08:26 PM

Somerandomfunc("blah") ConsoleWrite("blah", @error)


I mean that if it is successful write to STDOUT, if not write to STDERR.

I know exactly what you mean. I also can't understand why you can't understand what I mean. Look at these two situations and tell me if I'm still off base.
f($g) ConsoleWrite("It worked", @error)

If it works, it prints "It worked" on STDOUT. If it didn't work, it still prints "It worked" but on STDERROR, which makes no sense.
f($g) ConsoleWrite("It didn't work", @error)

If it works, it prints "It didn't work" on STDOUT, which makes no sense. If it didn't work, it prints "It didn't work" on STDERROR.

#11 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 28 February 2012 - 08:39 PM

Okay, I forgot that I'm using my own _UDF along with this :|

Here's how I have it:

AutoIt         
; #FUNCTION# ==================================================================================================================== ; Name ..........: _ConsoleWrite ; Description ...: A merge of ConsoleWrite and ConsoleWriteError ; Syntax ........: _ConsoleWrite($sText[, $fPipe = 0]) ; Parameters ....: $sText              - A string value. ;                 $fPipe               - [optional] A boolean value. Default is 0. ; Return values .: None ; Author ........: Robert Maehl ; Modified ......: 02/28/2012 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _ConsoleWrite($sText, $fPipe = 0) If $fPipe Then   ConsoleWrite($sText) Else   ConsoleWriteError($sText) EndIf EndFunc   ;==>_ConsoleWrite ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Not ; Description ...: Returns Not if needed ; Syntax ........: _Not([$fSuccess = @error[, $fCapital = 0]]) ; Parameters ....: $fSuccess            - [optional] A boolean value. Default is @error. ;                 $fCapital         - [optional] A boolean value. Default is 0. ; Return values .: None? ; Author ........: Robert Maehl ; Modified ......: 02/28/2012 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Not($fSuccess = @error, $fCapital = 0) If $fSuccess Then   If $fCapital Then    Return(" Not ")   Else    Return(" not ")   EndIf Else   Return(" ") EndIf EndFunc


And doing
_ConsoleWrite("It was" & _Not() & "successful")

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

SafeExecute, for picking and choosing what commands you want Execute to be able to run.


#12 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,257 posts

Posted 28 February 2012 - 11:52 PM

That's a pretty significant detail there. Do you see why I was saying what I was saying now?

Edited by Richard Robertson, 28 February 2012 - 11:52 PM.

  • shanet likes this

#13 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 01 March 2012 - 12:44 PM

That's a pretty significant detail there. Do you see why I was saying what I was saying now?


Yeah. I use the _Not() Function so often in my personal scripts I forgot I coded it. XD

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

SafeExecute, for picking and choosing what commands you want Execute to be able to run.


#14 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 01 March 2012 - 04:11 PM

It may be a significant detail but it doesn't change anything. Spend 3 seconds thinking about the problem and a solution presents itself.
  • James and shanet like this

#15 Raik

Raik

    Adventurer

  • Active Members
  • PipPip
  • 124 posts

Posted 20 April 2012 - 09:49 AM

one more reason against it:
if an error occurs, i want to write infos about the error-details to console, else possibly the resulting values from the succesful operation.

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)


#16 shanet

shanet

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 313 posts

Posted 16 May 2012 - 03:31 AM

I cant believe no one has said its a bad idea because they are actually 2 different streams...
My code does not have bugs! It just develops random features.My ProjectsPure randomness
  • Small Minds.......................................................................................................Simple progress bar that changes direction at either sides.
  • ChristmasIt AutoIt Christmas Theme..........................................................I WAS BOOOORED!
  • DriveToy..............................................................................................................Simple joke script. Trick your friends into thinking their computer drive is haywire!
In Development
  • Your Background Task Organiser
  • AInstall Second Generation
BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

#17 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,257 posts

Posted 16 May 2012 - 05:28 PM

I cant believe no one has said its a bad idea because they are actually 2 different streams...

That isn't a reason for a merged function not to exist. Two streams with a single write point can actually be very handy. For example, a logger that writes to the console and a file at the same time.

#18 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 16 May 2012 - 05:34 PM

Further, the fact that it is two streams is the entire point of having code branch to write to one stream or another based on a specific condition. If the two streams were the same then this thread would not exist. So yeah, you resurrected a warm corpse just to say something amazingly stupid. /slowclap

#19 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,796 posts

Posted 17 May 2012 - 12:44 AM

10 bugs on 'code readability'.





Also tagged with one or more of these keywords: STDIO, STDOUT, STDERR

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users