Dear all
I am a new, (yes very new) student, attempting to learn how to Programming in IDL (I tried these on IDL Version 6.3).
When I coded a simple program to get information from Keyboard, the code is exactly below:
PRO GetInfor
; do nothing
;myArray
END
FUNCTION GetInput, myArray, nElements
myArray=MAKE_ARRAY(nElements,/INTEGER ,value=0)
FOR i=0, nElements DO BEGIN
READ, myArray[i]
ENDFOR
T = myArray
RETURN, T
END
When I called getInput from the other Pro called Display.pro
PRO Display
T=getInput(myArray,5)
FOR i=0,5 DO BEGIN
PRINT, T[i]
ENDFOR
END
The result is:
So I saw the for loop in the first function did not work at all.
Please tell me what happened? And could you help me to solve it?
IDL> display
0 0 0 0 0Attempt to subscript MYARRAY with I is out of range.
Execution halted at: GETINPUT 9 C:\IDLExercises\getinfor.pro
DISPLAY 3 C:\IDLExercises\display.pro
$MAIN$
|