Hi,
I need help in writing a file with CWRITE. My goal is to write an array of 1000 elements into a file, one value at one row. Values are readings from analog signal (0.0-1.0). I need to transfer the values for further processing in Excel.
I tried this
Code
DEF writeFile ( )
; Read sensor
FOR I=1 TO bufferSize
buffer[I]=$ANIN[1]
WAIT SEC 0.001
ENDFOR
; Create file
CWRITE($FCT_CALL, STAT, MODE, "krl_fopen", "laserReadings.TXT", "w",HANDLE)
; Write file
FOR I=1 TO bufferSize
CWRITE($FCT_CALL, STAT, MODE, "krl_fprintf", HANDLE, "%f", buffer[I])
ENDFOR
; Close file
CWRITE($FCT_CALL, STAT, MODE, "krl_fclose", HANDLE)
END
Display More
This puts all the values in one row. Let's say I have three values 0.111, 0.222, 0.333. The resulting file has one string 0.1110.2220.333.
Any suggestions how to add a linebreak after every value?
KR C4 compact
KSS Version 8.3.27