Q Format Code

Available Format Codes

The Q format code returns the number of characters in the input record remaining to be transferred during the current read operation. It is ignored during output formatting.

The syntax is:

q 

Format Q is useful for determining how many characters have been read on a line. For example, the following IDL statements count the number of characters in file demo.dat:

;Open file for reading. 
OPENR, 1, "demo.dat" 
 
;Create a longword integer to keep the count. 
N = 0L 
 
;Count the characters. 
WHILE(~ EOF(1)) DO BEGIN 
  READF, 1, CUR, FORMAT = '(q)' & N = N + CUR  
ENDWHILE 
 
;Report the result. 
PRINT, FORMAT = '("counted", N, "characters.")' 
 
;Close file. 
CLOSE, 1