LINE INPUT #n, stringvar$Reads an entire line from an open file into a string variable, discarding the trailing CR/LF. In V13, the implementation was reworked from a single bulk ReadFile call to a character-by-character read loop that correctly handles CR, LF, and CRLF line endings.
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN() AS LONG
LOCAL ln AS STRING
OPEN "data.txt" FOR INPUT AS #1
WHILE NOT EOF(1)
LINE INPUT #1, ln
PRINT ln
WEND
CLOSE #1
FUNCTION = 0
END FUNCTION
| File Content | Result in var$ |
|---|---|
Hello\r\n | "Hello" |
World\n | "World" |
Line\r | "Line" |
NoNewline | "NoNewline" |
; Read one byte at a time until CR, LF, or EOF __pb_liread_loop: mov rcx, [rbp - handle_offset] lea rdx, [rbp - one_byte_temp] mov r8, 1 ; read 1 byte lea r9, [rbp - bytes_read] mov [rsp + 32], 0 call [__imp_ReadFile] cmp rax, 0 je __pb_liread_eof mov al, byte [rbp - one_byte_temp] cmp al, 13 ; CR je __pb_liread_check_lf cmp al, 10 ; LF je __pb_liread_done ; Store byte in buffer, increment position jmp __pb_liread_loop __pb_liread_check_lf: ; Peek ahead for LF after CR (CRLF handling) ; If LF follows, consume it __pb_liread_done: ; NUL-terminate buffer
result$ = FORMAT$(numeric)pb_str64_format_i64, pb_str64_format_d (pb_string64.c)V13 adds runtime helper functions for numeric formatting (pb_str64_format_i64 for integers, pb_str64_format_d for doubles). These provide a practical numeric-to-string conversion subset. Full PB picture/mask formatting remains future work.
LOCAL s AS STRING LOCAL n AS LONG n = 12345 s = FORMAT$(n) ' "12345"
LOF(#n) | EOF(#n)Both use GetFileSize internally. EOF compares current file pointer position against total size. File number must be a constant 1..15.