Professional Web Applications Themes

Cursor moving in one position - PERL Beginners

Hi all, in some aplicantions, we can see the cursor moving in one position, like an "indicator of application is running". In the examples that I see, they have made in C/C++. It is possible in perl? Sorry my bad english. Thanks in advance! Ricardo Pichler...

  1. #1

    Default Cursor moving in one position

    Hi all,
    in some aplicantions, we can see the cursor moving in
    one position, like an "indicator of application is running".
    In the examples that I see, they have made in C/C++.
    It is possible in perl?

    Sorry my bad english.
    Thanks in advance!
    Ricardo Pichler

    Ricardo Pichler Guest

  2. #2

    Default Re: Cursor moving in one position

    This for win32, so you have to escape the double quotes on the inside:

    perl -e "$|++; while (1) {print \"\b+\";sleep 1;print \"\b-\";sleep 1;}"

    You'll probably find the use of "\" and "/" to make a spinner (at least
    under win32) a good way to wait for the paint to dry.... ;-}


    At 04:44 PM 2/9/04 -0300, you wrote:
    >Hi all,
    >in some aplicantions, we can see the cursor moving in
    >one position, like an "indicator of application is running".
    >In the examples that I see, they have made in C/C++.
    >It is possible in perl?
    >
    >Sorry my bad english.
    >Thanks in advance!
    >Ricardo Pichler
    >
    >
    >--
    >To unsubscribe, e-mail: [email]beginners-unsubscribeperl.org[/email]
    >For additional commands, e-mail: [email]beginners-helpperl.org[/email]
    ><http://learn.perl.org/> <http://learn.perl.org/first-response>
    Tim Guest

  3. #3

    Default Re: Cursor moving in one position

    Thanks for your reply!
    I go learn more about your example!

    Regards,
    Ricardo Pichler
    ----- Original Message -----
    From: "Tim" <timlhuntmindspring.com>
    To: "Ricardo Pichler" <ricardopichler.com.br>
    Cc: <beginnersperl.org>
    Sent: Monday, February 09, 2004 4:53 PM
    Subject: Re: Cursor moving in one position

    > This for win32, so you have to escape the double quotes on the inside:
    >
    > perl -e "$|++; while (1) {print \"\b+\";sleep 1;print \"\b-\";sleep 1;}"
    >
    > You'll probably find the use of "\" and "/" to make a spinner (at least
    > under win32) a good way to wait for the paint to dry.... ;-}
    >
    >
    > At 04:44 PM 2/9/04 -0300, you wrote:
    > >Hi all,
    > >in some aplicantions, we can see the cursor moving in
    > >one position, like an "indicator of application is running".
    > >In the examples that I see, they have made in C/C++.
    > >It is possible in perl?
    > >
    > >Sorry my bad english.
    > >Thanks in advance!
    > >Ricardo Pichler
    > >
    > >
    > >--
    > >To unsubscribe, e-mail: [email]beginners-unsubscribeperl.org[/email]
    > >For additional commands, e-mail: [email]beginners-helpperl.org[/email]
    > ><http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    Ricardo Pichler Guest

  4. #4

    Default Re: Cursor moving in one position

    On Mon, 9 Feb 2004, Ricardo Pichler wrote:
    > Hi all,
    > in some aplicantions, we can see the cursor moving in
    > one position, like an "indicator of application is running".
    > In the examples that I see, they have made in C/C++.
    > It is possible in perl?
    >
    > Sorry my bad english.
    > Thanks in advance!
    > Ricardo Pichler
    First, your English is fine. Much better than my Portuguese would be!

    I tested the following on RedHat Linux 9.0 using Perl 5.8.0. It makes a
    rather slow spinner. The alarm() function only has resolution to about 1
    second. Spinning faster than once a second or so would require using one
    of the other methods mentioned if you do a "perldoc -f alarm", such as
    Time::HiRes from CPAN. I don't know if this works the same in Windows or
    not. I don't have Perl on my Windows box.

    #!/usr/bin/perl
    use strict;
    use warnings;
    our $click=0;
    $|=1;
    $SIG{ALRM}=sub {
    if ($click==0) { print "|\b";$click=1}
    elsif ($click==1) {print "/\b";$click=2}
    elsif ($click==2) {print "-\b";$click=3}
    else {print "\\\b";$click=0}
    alarm(10);
    };
    print "setting alarm\n";
    alarm(10);
    print "entering for loop\n";
    for (;;) { 1}

    Replace this for() loop with your code. Note that the $SIG{ALRM}
    subroutine must set the alarm again. Also note that only one alarm can be
    set at a time. If you set another alarm, the previous alarm is canceled.
    This means you can cancel your "spinner" using

    alarm(0);

    Hope this of use to you.


    --
    Maranatha!
    John McKown

    John McKown Guest

  5. #5

    Default Re: Cursor moving in one position

    hi Ricardo Pichler
    Its possible in perl using the module "Win32::Console::ANSI" .
    visit the following link for more..
    http://search.cpan.org/~jlmorel/Win32-Console-ANSI-1.04/lib/Win32/Console/ANSI.pm#AUXILIARY_FUNCTIONS
    cmkswamy@gmail.com Guest

Similar Threads

  1. HELP! DIV throws off position of cursor
    By norrisoft in forum Macromedia Dynamic HTML
    Replies: 22
    Last Post: May 8th, 11:02 AM
  2. setting cursor position
    By higgins1b in forum Macromedia Flex General Discussion
    Replies: 3
    Last Post: November 30th, 04:22 AM
  3. How can I can I get the cursor mouse position (x, y) ??
    By Pieratos@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 8
    Last Post: April 7th, 03:52 PM
  4. cursor in position
    By Gonzosez in forum ASP
    Replies: 6
    Last Post: September 19th, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139