View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Enumerated variable type

Elden Paul Iverson wrote on Apr 24, 2008

I would like to know how I can specify a range of values when enumerating a prompt. In the past I have just specified the exact entries that were possible but would prefer to just give a range and somehow require that only integers be entered from that range (i.e., string flux_per {prompt="Enter the percentage of flux to use for each star", enum="80-98"}.

Thanks.

-Paul

Mike Fitzpatrick wrote on Apr 24, 2008

Use the 'min' and 'max' parameter attributes, e.g.


procedure test (range)

int     range                   { prompt="range", min=80, max=98 }

begin
    print (range)
end


Cheers,
-Mike

Elden Paul Iverson wrote on Apr 24, 2008

Is there a way to modify the enumerated type through user-prompted input while a script is being run (i.e., modify the max range based on input from the user)? I kinda doubt it but thought I should ask.

Thanks.

-Paul

Mike Fitzpatrick wrote on Apr 24, 2008

It's just a matter of resetting the parameter attribute 'p_max' , e.g.


ecl> =display.frame.p_max
4
ecl> display.frame.p_max=23
ecl> =display.frame.p_max
23


There is likewise a 'p_min' attribute for the minimum value.

-Mike

craigswenson wrote on Apr 24, 2008

Mike-

On a related topic, Paul and I have a situation where we would like to use a string enumerated type where the user can input a number 1-16, 'Next', or 'Finish'. So we set up a prompt that looks something like this:

string delete_file_num		{prompt="Enter the number of the file to delete",enum="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|Next|Finish"}


The problem is that if we enter '1' at the prompt, we get an 'ambiguous response'. We can enter anything 2-16, 'Next', or 'Finish' and it work fine. Why does it have a problem with '1'?

Also, what is the parameter attribute for enum? p_enum doesn't seem to work.

Thanks

-Craig

Mike Fitzpatrick wrote on Apr 24, 2008

Because '1' is the starting character for 10, 11, 12, etc It is a string type and so abbreviations are permitted so long as they are unique.

Additionally, the first character of the enum string should be the delimiter not the first value, i.e. use "enum="|1|2|..." not "enum='1|2|...."

Also, what is the parameter attribute for enum? p_enum doesn't seem to work.


Enumerated values are store in the parameter 'min' field, i.e. the p_min attribute.

Cheers,
-Mike

Last post on Apr 24, 2008