Fixing "Keyword parameters not allowed" Error in IDL Function

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 14K views
big man
Messages
242
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.