Robot Code!!!

Status
Not open for further replies.

Spectrum

Registered Senior Member
To be entered into QBasic which can be found on Windows software under the oldmsdos folder.

THIS$="THISFILE.BAS"
THAT$="FILELOG.DOC"
OPEN THIS$ FOR RANDOM AS #1 LEN=1
OPEN THAT$ FOR RANDOM AS #2 LEN=1
SIZE&=LOF(1)*
FOR LETTER&=1 TO LOF(1)
FIELD #1, 1 AS LETTER$
FIELD #2, 1 AS LETTER$
GET #1, LETTER&
PUT #2, LOF(2)+2
GET #2, LOF(2)-1
MM&=ASC(LETTER&)
PRINT MM&;" ";
LETTER$=CHR$(PEEK(MM&))
PUT #1, SIZE&+LETTER&
NEXT LETTER&
CLOSE
OPEN THIS$ FOR BINARY AS #1
DLT$="'"
RN$="RUN THIS$"
PUT #1, SIZE&-LEN(RN$)**, DLT$
FOR LETTER&=1 TO LEN(RN$)
LETTER$=MID$(RN$, LETTER&, 1)
PUT #1, LOF(1)+1, LETTER$
NEXT LETTER&
CLOSE
RUN THIS$

*This value must be input manually because the length of the file grows. Perhaps you could write a code to discover this value:

FILE$="FILENAME"
OPEN FILE$ FOR RANDOM AS #1 LEN=1
PRINT LOF(1)
CLOSE

:)

**The length of RN$ is not a sufficient value but 'SIZE&-12' should be.

ENJOY :D
 
Last edited:
Its a short QBASIC program that doesn't appear to do anything useful and I think it has a couple of mistakes in it, e.g., I think line 15 should be:

PUT #1, SIZE&, LETTER&

although I may be wrong.
 
Yes you are wrong. This program generates random numbers which become ASCII symbols. :) The program should look like this:

THIS$=[THISFILE.BAS]
THAT$=[FILELOG.DOC]
OPEN THIS$ FOR RANDOM AS #1 LEN=1
OPEN THAT$ FOR RANDOM AS #2 LEN=1
SIZE&=LOF(1)*
FOR LETTER&=1 TO LOF(1)
FIELD #1, 1 AS LETTER$
FIELD #2, 1 AS LETTER$
GET #1, LETTER&
PUT #2, LOF(2)+2
GET #2, LOF(2)-1
PUT #1, SIZE&+LETTER&
NEXT LETTER&
CLOSE
OPEN THIS$ FOR BINARY AS #1
DLT$="'"**
RN$="RUN THIS$"
PUT #1, SIZE&*-LEN(RN$), DLT$
CLOSE
RUN THIS$

*This value must be input manually.
**DLT is a REM apostrophe
 
OMG that is the worst bit of code i have seen in years... And what the hell does this have to do with robots???
 
Status
Not open for further replies.
Back
Top