in the place where you increment $num do you re-assign $line?

$num++; ## this changes only $num
$line=$array[$num]; # this changes $line to the new index that $num is now.

if you don't do the second line then $line will still be 
$array[whatever $num was before]

you need to reassign $line to the new line.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 05, 2002 10:06 AM
To: [EMAIL PROTECTED]
Subject: accessing an array with a variable


Hi,

I believe it is possible to access an array through a variable, but I'm
ghaving trouble doing it.
I want to read in a text file and display it, on line at a time, depending
on an 
increment counter triggered by a 'next' or 'previous' button.

I am trying to do this with Perl/Tk, but it fails to work, only displaying
the initial line of the text file:

This is the definition of the variable

        $line=$array[$num];

$num is incremented elsewhere with the click of the button.

This is the attempt to display the variable on screen.

$txtmain->configure(-textvariable => \$line,
        .....);

I know that the incrementing is successful because replacing $line with $num
as the -textvariable gives the right output.

Any help would be greatly appreciated.


Dennis Warren

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to