View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Trouble creating a package

JanRap wrote on May 17, 2010

I am trying to create a simple package to test whether I can get one task to call another.

Below is the package file for the "test" package (test.cl) as well as the two tasks I am using.

# Package script task for TEST package

# Load the neccesary packages

	noao
	astutil
	imred
	ccdred
	ccdtest
	vtel
	digiphot
	daophot
	photcal
	ptools
	obsutil
	images
	imutil

set	test	= "/iraf/extern/practice/"

package	test		# Define package

task test_maintask = "test$test_maintask.cl"
task test_calledtask = "test$test_calledtask.cl"

clbye()



procedure test_maintask (x)

real   x {prompt = "Enter a value for x"}

begin

real y

y = test_calledtask (x)

print(y)

end


procedure test_calledtask (input)

begin

y = input*input

return y

end


I have also added the following to the extern.pkg file in /iraf/iraf/unix/hlib/

reset	test	= /iraf/extern/practice/
task	test.pkg	= test$test.cl


Lastly, I made sure that the permissions to all the folders and files have been set correctly.

When I try to load the "test" package from the cl, I get the following error message:

ecl> test
ERROR: task 'test' has no param file

Thanks in advance for any advice.
- Daniel

Mike Fitzpatrick wrote on May 17, 2010

All your files appear to be correct. The trick to remember is that a package script is just like other script tasks and the task declaration determines whether the system looks for a parameter file. For example, "task foo = /path/foo.cl" means there are parameters, but "task $foo = ...." does not. Package parameter files can be used to define global parameters for all tasks in the package, but if you're not using it then try declaring with the '$' in front of the package name.

JanRap wrote on May 17, 2010

Thank you very much for the advice! I added the '$' to the package definition and it loads perfectly now!! Unfortunately, I am running into another error now. When running test_maintask, I get the following:

$test> test_maintask
Enter a value for x: 3
ERROR: unknown function 'test_calledtask'
"y = test_calledtask (x)"
line 9: test$test_maintask.cl
called as: 'test_maintask ()'

I tried declaring y in test_calledtask, but nothing changed. Should I declare y there?

I am puzzled by the error message, since test_calledtask definitely loaded when I loaded the package.

-Daniel

Mike Fitzpatrick wrote on May 17, 2010

I should have read the actual tasks more closely: Functions are builtin to the CL and cannot be declared dynamically as tasks. To do what you want you would need something like:


procedure tmain (x) 

real   x 		{ prompt = "Enter a value for x"	} 

begin 
    tcalled (x)

    print (tcalled.output) 
end


and


procedure tcalled (input)

real	input
real	output

begin 
    output = input * input 
end


Since you can return the value, you need to pass it back by updating a parameter and using it in the calling task. Otherwise, you could do something like have 'tcalled' simply print the value and 'tmain' call it, i.e.

tmain (4) | scan (y)


-Mike

JanRap wrote on May 17, 2010

Thanks Mike. Your first suggestion works 100%. I haven't quite managed to get the "tmain (4) | scan (y)" way to work yet, but I'll figure it out. Thanks again, you have been very helpful.

-Daniel

Last post on May 17, 2010