Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

popup_menu

Status
Not open for further replies.

abovebrd

IS-IT--Management
May 9, 2000
690
US

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






 
I think this will work....

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


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

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

'hope this helps....


keep the rudder amid ship and beware the odd typo
 

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

goBoating,

Your my hero.

Thank you, the above code worked perfectly.






-Danny






 
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






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

}
print p(&quot;POP UP MENU &quot;, popup_menu(&quot;var1&quot;, \@steps));
[/tt]
But this will also cause it to end on 40.5 instead of 40. You will want to change the while condition to:
[tt]
while ($num < 40)
[/tt]


Alternative method: Just push a &quot;0&quot; onto the list to start with.
[tt]
$num = 0;
push @steps, $num;
while ($num <= 40)
{
$num += .5;
push @steps, $num;
}
print p(&quot;POP UP MENU &quot;, popup_menu(&quot;var1&quot;, \@steps));
[/tt]

&quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
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 (&quot;POP UP MENU&quot;: , popup_menu(&quot;var1&quot;, \@choices));

It seems to be very &quot;dirty or maybe sloppy code&quot; but it works !!

Thanks guys

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


-Danny






 
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
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top