Make me a scrolling marquee

PowerShell, 118 113 112 108 102 101 99 96 - 10% = 86

Code

$s=(Read-Host)*180;for(){Write-Host($s.substring(($i=++$i%80),80)+"`r")-N -F R -B 0;sleep -m 99}

With the caveat that it now begins the first loop with the second character; The rules don't say it has to start from the front of the string, and the first one is included overall, so that's fine by me. I will get it to 100 chars somehow - edit: thanks @ConnorLSW for the edits to get it below 100.

Instructions

  1. Run PowerShell (normal console, it doesn't work in PowerShell ISE)
  2. Paste the single line version into PoSH, press enter
  3. Type a message, press enter
  4. Ctrl-C to break

Output

PowerShell marquee example output

Notes

A more readable version with the variable names and parameters filled out a bit:

$test = (Read-Host) * 180
for () {
    Write-Host ($text.substring(($i=++$i%80), 80)+"`r") -NoNewLine -ForegroundColor Red -BackgroundColor Black
    sleep -Miliseconds 99
}
  • The parameters only need to be long enough to be unique, so -F R is unique enough to set a Red ForegroundColor, for example.
  • 'Black' has to be 'Bla' to be unique compared to 'Blue', but -B 0 sets it to color Enum value 0 which is interpreted as Black.

Alternative, more 'correct' marquee:

The reference code doesn't handle strings longer than 80 characters nicely, skipping anything in the message past ~160 characters, and it glitch-resets every 99*len(string) characters. e.g. if the sign width was 5 characters long, it does this:

   here is my long test input
 0 |here |            
 1  |ere i|          ^^^^ never shown
 2   |re is|
 3    |e is |
 4     | is m|
 0 |here |
 1  |ere i|
    ...

This version indexes modulo the text length instead of the sign width, so it runs through the whole string. 106 - 10% = 95 chars.

$l=($s=Read-Host).Length;for(){Write-Host(($s*160).substring(($i=++$i%$l),80)+"`r")-N -F R -B 0;sleep -m 99}

Alternative: sign which cycles like the .gif in the question, 118-10%=106

Because it looks better.

$s=' '*80+(read-host)+' '*80;for(){write-host($s.Substring(($i=++$i%($s.length-80)),80)+"`r")-N -F R -B 0;sleep -m 99}

Alternative sign example animation


Matlab, 76 bytes

What I think is nice here is that you can have vectors as array indices. This returns a vector of the corresponding array entries, which makes it very easy to append the given string independently of the length.

a=input('');k=1:80;while 1;pause(.1);clc;k=mod(k+1,nnz(a));disp(a(k+1));end

Result:

enter image description here


CJam, 31 bytes

l80*{Dco_80<o(+es99+{es1$<}g;}h

Waits for exactly 100 ms.

This will only work with the official Java interpreter, since the online interpreter only shows output after exiting the program.

Red text on black background is possible in 40 (or 39) bytes, for a score of 36:

0000000: 6c 38 30 2a 7b 22 0d 1b 5b 33 31 3b 34 30 6d 22 6f 5f  l80*{"..[31;40m"o_
0000012: 38 30 3c 6f 28 2b 65 73 39 39 2b 7b 65 73 31 24 3c 7d  80<o(+es99+{es1$<}
0000024: 67 3b 7d 68                                            g;}h

How it works

l80*                             Read a line and repeat it 80 times.
    {                        }h  Do:
     Dco                           Print the character with code point 13.
        _80<o                      Print the first 80 characters of the string.
             (+                    Rotate the string one charcter to the left.
               es99+               Push the current time (ms) plus 99.
                    {     }g       Do:
                     es1$<           Compare the current time with the sum.
                                     Repeat the loop if 99 or less ms have passed.
                            ;      Discard the time stamp.
                                 Repeat the loop.

Tags:

Code Golf