×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

popup_menu

popup_menu

popup_menu

(OP)

I have a question related to popup_menu

I am using a print statement to create a popup_menu

print p("POP UP MENU ", popup_menu("var1", [ 1..40 ]));

This creates the values of 1 thru 40 in the pop up menu.
However I want to increment by .5 instead of 1
example

.5
1.0
1.5
2.0
2.5
3.0

Can this be done ? Or I should say with a minimal amount of work ?



Any ideas


-Danny
 
 


RE: popup_menu

I think this will work....

while ($num <= 40)
{
$num += .5;
push @steps,$num;
}


print p("POP UP MENU ", popup_menu("var1", @steps));

I'm not sure about the syntax.  You may have to play a little... maybe this....
print p("POP UP MENU ", popup_menu("var1", \@steps));

'hope this helps....


 
 
 keep the rudder amid ship and beware the odd typo

RE: popup_menu

(OP)

while ($num <= 40)
{
$num += .5;
push @steps,$num;
}
print p("POP UP MENU ", popup_menu("var1", \@steps));

goBoating,

Your my hero.

Thank you, the above code worked perfectly.






-Danny
 
 


RE: popup_menu

(OP)
How difficult would be to have this

0
0.5
1.0
1.5
2.0
2.5

etc ...

I guess I need to first value to be a zero.


-Danny
 
 


RE: popup_menu

  Predefine $num to 0 and switch the order of the code:
$num = 0;
while ($num <= 40)
{
push @steps,$num;
$num += .5;

}
print p("POP UP MENU ", popup_menu("var1", \@steps));

But this will also cause it to end on 40.5 instead of 40.  You will want to change the while condition to:

while ($num < 40)



Alternative method: Just push a "0" onto the list to start with.

$num = 0;
push @steps, $num;
while ($num <= 40)
{
$num += .5;
push @steps, $num;
}
print p("POP UP MENU ", popup_menu("var1", \@steps));


"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."

RE: popup_menu

(OP)
Thanks stillflame, and goBoating

Since I am still fairly new to perl, I just went ahead and create a array

@choices = ('0','.5.','1','1.5','2');
print p ("POP UP MENU": , popup_menu("var1", \@choices));

It seems to be very "dirty or maybe sloppy code" but it works !!

Thanks guys

Perl is pretty cool {I am just a perl newbie}


-Danny
 
 


RE: popup_menu

Danny, remember the Perl motto......
TIMTOWTDI
There is more that one way to do it.

What ever works ;^)

ps - the case could be made that your approach requires fewer CPU cycles.....   not a lot fewer, but, fewer...chuckle chuckle...


 
 
 keep the rudder amid ship and beware the odd typo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close