Fixing "Keyword parameters not allowed" Error in IDL Function

Click For Summary
The discussion addresses a compile error encountered in an IDL function when trying to use a keyword parameter. The error message "Keyword parameters not allowed in call" arises from incorrect syntax in the function definition. The suggested solution involves correcting the conditional statements to properly check for the keyword using the keyword_set function. Specifically, the syntax should be adjusted to separate the conditions for when the keyword is set and when it is not. Properly implementing these changes should resolve the compile error and allow the function to work as intended.
big man
Messages
241
Reaction score
0

Homework Statement


I've created a function inside IDL and I want to be able to specify the binsize.
That is, I want to have:

result = myfunction(array, keyword)

Whenever I add the keyword in the brackets there it says:

"Keyword parameters not allowed in call."


2. Relevant code

FUNCTION histimage, array, binsize=x

If KEYWORD_SET(x) then $

count = uintarr(256/x)
array = array*(1/x)
array=round(array)

*end if else begin
count = uintarr(256)

for j = 0,255 do begin
for k = 0,255 do begin
count(array(j,K)) = count(array(j,k)) + 1
endfor
endfor

Return, count

END

Histimage is the name of my function and binsize is the keyword. The point in the code where there is a * shows where I get a compile error as well. I can't see why I get this error and was hoping that someone could tell me if I've used incorrect syntax.
 
Physics news on Phys.org
Hi, hope this isn't too late to be of help, I stumbled across this looking for help on keyword syntax.

In IDL I think you need:

if keyword_set(x) then blah
if not keyword_set(x) then bleh

I think that's why you're getting a compile error at "endif else begin", as it's not the correct syntax for the keyword_set function.
 

Similar threads

Replies
7
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 24 ·
Replies
24
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K