Welcome to iraf.net Thursday, May 02 2024 @ 01:49 PM GMT


 Forum Index > Help Desk > Applications New Topic Post Reply
 Trouble creating a package
   
JanRap
 05/17/2010 10:02AM (Read 1624 times)  
+----
Newbie

Status: offline


Registered: 09/14/2009
Posts: 11
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.[code:1:031f3b7b56]# Package script task for TEST package# Load the neccesary packages noao
astutil
imred
ccdred
ccdtest
vtel
digiphot
daophot
photcal
ptools
obsutil
images
imutilset test = "/iraf/extern/practice/"package test # Define packagetask test_maintask = "test$test_maintask.cl"
task test_calledtask = "test$test_calledtask.cl"clbye()[/code:1:031f3b7b56][code:1:031f3b7b56]
procedure test_maintask (x)real x {prompt = "Enter a value for x"}beginreal yy = test_calledtask (x)print(y)end[/code:1:031f3b7b56][code:1:031f3b7b56]procedure test_calledtask (input)beginy = input*inputreturn yend[/code:1:031f3b7b56]
I have also added the following to the extern.pkg file in /iraf/iraf/unix/hlib/[code:1:031f3b7b56]reset test = /iraf/extern/practice/
task test.pkg = test$test.cl[/code:1:031f3b7b56]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 fileThanks in advance for any advice.
- Daniel

 
Profile Email
 Quote
fitz
 05/17/2010 10:02AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
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.

 
Profile Email
 Quote
JanRap
 05/17/2010 10:02AM  
+----
Newbie

Status: offline


Registered: 09/14/2009
Posts: 11
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

 
Profile Email
 Quote
fitz
 05/17/2010 10:02AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
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:[code:1:7dbcf30483]
procedure tmain (x) real x { prompt = "Enter a value for x" } begin
tcalled (x) print (tcalled.output)
end
[/code:1:7dbcf30483]and[code:1:7dbcf30483]
procedure tcalled (input)real input
real outputbegin
output = input * input
end
[/code:1:7dbcf30483]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.[code:1:7dbcf30483]tmain (4) | scan (y)[/code:1:7dbcf30483]-Mike

 
Profile Email
 Quote
JanRap
 05/17/2010 10:02AM  
+----
Newbie

Status: offline


Registered: 09/14/2009
Posts: 11
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

 
Profile Email
 Quote
   
Content generated in: 0.16 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login