Well, first of all, you can get rid of the line break that [tt]
PRINT[/tt] inserts by adding a semicolon ; to the end of the line. However, there is a much better way to build up a string. You can simply add them together as though they were numbers:
[tt]
a$ = "Hello,"
b$ = "world!"
c$ = a$ + " " + b$
[/tt]
After this short sequence, [tt]c$[/tt] will contain the string [tt]"Hello, world!"[/tt] (with the space).
In general, though, you should strive to avoid using [tt]
SHELL[/tt] whenever possible, because it makes your code require certain things of the OS. If the target system has a slightly different OS, or has been modified in some way (e.g., the command interpreter might not support the 'copy' command), then your code becomes broken. Consider the following snippet:
[tt]
LINE INPUT "Enter the number of the last file: ", a$
LINE INPUT "Enter the name of the output file: ", oFile$
lastFile% =
VAL(a$)
OPEN oFile$
FOR BINARY AS #1
IF LOF(oFile$)
THEN
PRINT "The output file already contains data. Overwrite [y/N]? ";
DO
a$ =
UCASE$(
INPUT$(1))
' read a character from the keyboard
IF a$ =
CHR$(13)
THEN a$ = "N"
'enter
IF a$ =
CHR$(27)
THEN a$ = "N"
'escape
LOOP UNTIL (a$ = "Y"
OR (a$ = "N"
PRINT a$
IF a$ = "N"
THEN END
CLOSE #1
' close the file,
KILL oFile$
' delete the existing one,
OPEN oFile$
FOR BINARY AS #1
' and start a new one
END IF
FOR i% = 1
TO lastFile%
iFile$ =
LTRIM$(
RTRIM$(
STR$(i%))) + ".mpg"
PRINT iFile$ + " ..."
ON ERROR GOTO notFound
OPEN iFile$
FOR INPUT AS #2
' check if it exists first
CLOSE #2
OPEN iFile$
FOR BINARY AS #2
ON ERROR GOTO 0
buffer$ =
SPACE$(4096)
bytesLeft& =
LOF(2)
DO WHILE bytesLeft&
IF bytesLeft& <
LEN(buffer$)
THEN
buffer$ = ""
' free the string space as a separate operation, otherwise
buffer$ =
SPACE$(bytesLeft&)
' it'll try to allocate more first
END IF
GET #2, , buffer$
' read in the buffer from the source file
PUT #1, , buffer$
' write the buffer to the output file
bytesLeft& = bytesLeft& -
LEN(buffer$)
totalBytes& = totalBytes& +
LEN(buffer$)
LOOP
CLOSE #2
NEXT i%
CLOSE #1
PRINT "Done!"; totalBytes&; "bytes copied."
END
notFound:
PRINT "Unable to access file "; iFile$; ", maybe it doesn't exist?"
IF i% < lastFile%
THEN
PRINT "Continue [Y/n]? ";
DO
a$ =
UCASE$(
INPUT$(1))
' read a character from the keyboard
IF a$ =
CHR$(13)
THEN a$ = "Y"
'enter
IF a$ =
CHR$(27)
THEN a$ = "N"
'escape
LOOP UNTIL (a$ = "Y"
OR (a$ = "N"
PRINT a$
IF a$ = "N"
THEN END
i% = i% + 1
iFile$ =
LTRIM$(
RTRIM$(
STR$(i%))) + ".mpg"
RESUME
ELSE
END
END IF
[/tt]
(not tested by the way

)
Though this kind of thing may be beyond your current levels of stamina, they should be for what you strive
