String manipulation is definitely possible in Basic. You’ll need to use LEN
to get the length of the string, then String$(1 TO 5)
to take a substring (in this case the first through fifth characters, 1-indexed). Here’s an example for removing the final character from a string:
A$ = "Test string,"
L% = LEN A$
PRINT A$(1 TO (L% - 1))
//Prints "Test string"
Determining how many lines are in a file should also be possible, though file parsing is a little trickier. If every line ends with a line feed character, this code should provide the number of lines:
OPEN "file:/usr/lines.txt" FOR BINARY INPUT AS 1
L% = 1
ReadNext:
IF EOF 1 THEN GOTO ReadDone //Go to ReadDone after reaching end of file
CHAR$ = GET 1,1 //Get next character
IF CHAR$ = CHR$(10) THEN //If character is line feed
L% = L% + 1 //Then increment L%
ENDIF
GOTO ReadNext
ReadDone:
PRINT L%
CLOSE 1