I have an old BASIC program which I unfortunately no longer have a copy of. I do, however, have the original source code in a research report which I have scanned onto my computer and saved as a text file. I have not had any luck copying the text into either Quick Basic 1.1 or 4.5. Any Ideas?

Dani AI

Generated

A short, practical follow-up to the thread: after 's suggestion and 's confirmation that a simple paste fixed the immediate case, the bigger, recurring problem with scanned source is OCR and encoding artifacts rather than QuickBASIC itself. The checklist and tiny script below automate the usual cleanup so a scanner/OCR dump becomes a usable .BAS file.

Common OCR/format issues and quick remedies

  • Curly quotes, long dashes and ellipses turned into characters QuickBASIC dislikes — normalize them to straight quotes, plain hyphens and three dots.
  • Hidden or printer control bytes and BOMs — strip non-printing controls while preserving newlines and tabs.
  • Printed line numbers or page headers introduced by the scanner — remove leading numbers on each line.
  • Word-wrap hyphenation that split statements across lines — join hyphenated breaks.
  • Tabs, multiple spaces, stray non-ASCII glyphs — collapse/replace and save as plain ASCII with a .BAS extension.

A small Python utility that automates the fixes (save as e.g. clean_qb.py):

#!/usr/bin/env python3
# Usage: python clean_qb.py input.txt output.bas

import sys, re

if len(sys.argv) != 3:
    print("Usage: python clean_qb.py input.txt output.bas"); sys.exit(1)

inp, outp = sys.argv[1], sys.argv[2]

mapping = {
    '\\u2018': "'", '\\u2019': "'", '\\u201C': '"', '\\u201D': '"',
    '\\u2013': '-', '\\u2014': '-', '\\u2026': '...'
}

with open(inp, 'rb') as f:
    text = f.read().decode('utf-8', 'replace')

for k, v in mapping.items():
    text = text.replace(k, v)

text = ''.join(ch for ch in text if ord(ch) >= 32 or ch in '\\r\\n\\t')
text = re.sub(r'(?m)^\\s*\\d+\\s+', '', text)        # remove leading printed numbers
text = re.sub(r'-\\r?\\n\\s*', '', text)             # join hyphenated wraps
text = re.sub(r'[ \\t]+', ' ', text)                 # collapse whitespace
text = text.replace('\\r\\n', '\\n').replace('\\r', '\\n').replace('\\n', '\\r\\n')

with open(outp, 'wb') as f:
    f.write(text.encode('ascii', 'replace'))

After cleaning, give the file a .BAS name and open it in the QuickBASIC 4.5 editor (on modern machines QuickBASIC is commonly run inside DOSBox; mount the folder and open the cleaned file). If syntax errors remain, inspect OCR-prone tokens (examples: F0R for FOR, 1 vs l, 0 vs O) and fix those lines manually. This approach prevents repeated trial-and-error pastes and makes the source reliably editable and compilable.

Recommended Answers

All 4 Replies

Just curious: I thought we can actually edit a text file in Quick BASIC?

I have an old BASIC program which I unfortunately no longer have a copy of. I do, however, have the original source code in a research report which I have scanned onto my computer and saved as a text file. I have not had any luck copying the text into either Quick Basic 1.1 or 4.5. Any Ideas?

The file contains programming code which i wish to copy and paste into quick basic.

If you can open the old code in notepad, then copy by highlighting/then right click ->copy, you can paste it into qbasic/quickbasic with the following.

(be sure the line lengths are not over 255 characters, and that
they end in CRLF. Also don't try to do it all at one time if it's more than a few
lines long; remove any control characters if necessary/possible ).

click in the qb program where you want the text.
right click on the Qbasic/QuickBasic in the tray. Go to Edit then paste

Another note: If you are trying to post entire SUBS/FUNCTIONS dont.
Make the sub or function in the normal way through the edit option of QB.
Then past from after SUB subname/FUNCTION functionname up to END SUB/END FUNCTION but not including it.

thank its works :cheesy:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.