Login Register






[JFF] CMD Matrix filter_list
Author
Message
RE: [JFF] CMD Matrix #11
(01-02-2014, 05:03 AM)ArkPhaze Wrote:
(12-19-2013, 10:04 PM)Zedex Wrote: I can see an error in your code. It should be like this:
Code:
@echo off :top color 0a echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% goto top

Now, the text will keep It's color.

There is no error in his code, I don't know why you'd think that. The color stays set for the session until it is changed. Why continually set color each loop?

The code looks like this:
Code:
@echo off color 0a :top echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% goto top

Now, the color would set once at the top, so when it comes to the loop the color isn't inside the loop, so the text would turn green once and then it would turn grey as normal.

Reply

RE: [JFF] CMD Matrix #12
(01-02-2014, 12:45 PM)Zedex Wrote:
(01-02-2014, 05:03 AM)ArkPhaze Wrote:
(12-19-2013, 10:04 PM)Zedex Wrote: I can see an error in your code. It should be like this:
Code:
@echo off :top color 0a echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% goto top

Now, the text will keep It's color.

There is no error in his code, I don't know why you'd think that. The color stays set for the session until it is changed. Why continually set color each loop?

The code looks like this:
Code:
@echo off color 0a :top echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% goto top

Now, the color would set once at the top, so when it comes to the loop the color isn't inside the loop, so the text would turn green once and then it would turn grey as normal.

You seriously don't know how batch works do you? The color command within cmd.exe sets a color for a batch session, there is no scope within a batch script. There are what are called SESSIONS, and you can manipulate that with setlocal. The color command however is global to the cmd.exe process itself, and not any session.

Here is the usage for the color command:
Code:
Sets the default console foreground and background colors. COLOR [attr] attr Specifies color attribute of console output Color attributes are specified by TWO hex digits -- the first corresponds to the background; the second the foreground. Each digit can be any of the following values: 0 = Black 8 = Gray 1 = Blue 9 = Light Blue 2 = Green A = Light Green 3 = Aqua B = Light Aqua 4 = Red C = Light Red 5 = Purple D = Light Purple 6 = Yellow E = Light Yellow 7 = White F = Bright White If no argument is given, this command restores the color to what it was when CMD.EXE started. This value either comes from the current console window, the /T command line switch or from the DefaultColor registry value. The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute the COLOR command with a foreground and background color that are the same. Example: "COLOR fc" produces light red on bright white

Would you mind actually doing some research before trying to prove another member wrong? Or at least running the code to even verify what you're saying, because you clearly haven't done so or you would've known how wrong you are right here. :S

It's a few lines in a batch script, I don't see how it'd take more than 5 seconds to copy and paste that into a file, save it, and run it.

Either way you are wrong here. Proof of my claims:
Code:
@echo off & setlocal enabledelayedexpansion setlocal set i=10 color 0a echo !i! endlocal pause :loop_a echo !i! goto :loop_a

If you have no clue how the color command works though and how far it extends, you won't understand sessions either at this point.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply