
May 15th, 2006, 10:55 AM
| | | printf() with control character
Hello,
I'm trying to write a rotational symbol in a CLI process, to report
activity to the user console, using printf( "%s\b", symbol ); but I see
the control character (\b) is been printed out instead of backspacing.
Is there any work around ?
Thanks in advance,
Sebastián. | 
May 15th, 2006, 01:05 PM
| | | Re: printf() with control character
On 2006-05-15, Sebastian Araya <numisys@gmail.com> wrote:[color=blue]
> Hello,
>
> I'm trying to write a rotational symbol in a CLI process, to report
> activity to the user console, using printf( "%s\b", symbol ); but I see
> the control character (\b) is been printed out instead of backspacing.
>
> Is there any work around ?[/color]
Tried "%s\\b" or '%s\\b' already?
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be> | 
May 16th, 2006, 11:45 AM
| | | Re: printf() with control character
Hello,
and thanks for your answer.
Yes, I tried it, but it didn't work... perhaps I need to use NCurses
( http://www.zend.com/pecl/tutorials/ncurses.php) ??
Best,
Sebastian | 
May 16th, 2006, 12:05 PM
| | | Re: printf() with control character
Tim Van Wassenhove wrote:[color=blue]
> On 2006-05-15, Sebastian Araya <numisys@gmail.com> wrote:[color=green]
>> Hello,
>>
>> I'm trying to write a rotational symbol in a CLI process, to report
>> activity to the user console, using printf( "%s\b", symbol ); but I
>> see the control character (\b) is been printed out instead of
>> backspacing.
>>
>> Is there any work around ?[/color][/color]
What about:
printf( "%s%c", symbol,8);
%c:
c - the argument is treated as an integer, and presented as the character
with that ASCII value
Then again, I know nothing about CLI.
Grtz,
--
Rik Wasmus | 
May 16th, 2006, 12:25 PM
| | | Re: printf() with control character
Hello,
I figured out with ANSI terminal control codes; here is a little
example:
<?
$sym = "|/-\\";
while( True )
for( $i = 0; $i!= 4; $i++ )
{
printf( "%s\x1b[D", substr( $sym, $i, 1 ) );
sleep(.25);
}
?>
I tested in a Gentoo 2006.0 using a SSH terminal under Windows
(PuTTy).
Best,
Sebastian | 
May 16th, 2006, 12:35 PM
| | | Re: printf() with control character
Hello Tim,
thanks again for your answer.
I think that, in PHP-CLI (console) environment, the screen is treated
as a common file, and every character output is send in a raw mode...
like if you use PHP under web development (where every output byte is
send through the net).
So, seeing Stefan Walk ProgressBar
( http://pear.php.net/package/Console_ProgressBar) I realized that using
ANSI terminal chars' control, you change the console behavior, so it
apparently deletes a char and writes a new one.
Best,
Sebastian | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 205,338 network members.
|