file problems

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Guest
file problems

Post by Guest » Wed Apr 16, 2003 5:12 pm

if someone can help me please....

im writing 2 programs...

1 is a bulletins program i figured this would be simple

small portion of whaty i want it to do is this

print " 1. bulletin 1
print " 2. bulletin 2
print:color 11
input " Select Bulletin or (Q)uit :>",input$

if input$="1" then goto 200
if input$="2" then goto 200
if input$="Q" or input$="q" then goto 500
goto top

200 i want a command here to print dos files
500 system

i know theres prolly an easy way to do this the above peice of code was just a ref

im trying to figure out how to display DOS text files and display dos .ANS files

Daniel Spain
www.azonebbs.net229.ca

John_Schofield
Full Member
Posts:36
Joined:Tue Mar 18, 2003 3:04 am
Location:Lancashire, UK
Contact:

Re: file problems

Post by John_Schofield » Thu Apr 17, 2003 4:20 am

do you want to display the bulletin on screen or out to a printer? It makes a difference!

Also, is your bulletin a plain old ascii text file or something else?

User avatar
Baz
Jr. Member
Posts:11
Joined:Mon Mar 10, 2003 9:55 pm
Location:Suffolk UK

Re: file problems

Post by Baz » Thu Apr 17, 2003 5:33 am

Hi.
Ok its not purfik but here goes.
Hope some of it is usefull
depending on your flavour of windows as what information (if any) may be viewed with the files
---------------------------------------------------------
start:
ON ERROR GOTO 0
GOSUB showmenu

DO
k$ = UCASE$(INKEY$)
IF k$ = "1" THEN GOSUB example1: GOSUB footer
IF k$ = "2" THEN GOSUB example2: GOSUB footer
IF k$ = "3" OR k$ = "4" OR k$ = "5" THEN GOSUB file: GOSUB footer
IF k$ = "M" THEN GOSUB showmenu
IF k$ = "Q" THEN END
LOOP


showmenu:
CLS
COLOR 3
LOCATE 12, 30: PRINT "1 = Example 1"
LOCATE 13, 30: PRINT "2 = Example 2"
LOCATE 14, 30: PRINT "3 = Open AUTOEXEC.BAT"
LOCATE 15, 30: PRINT "4 = Open CONFIG.SYS"
LOCATE 16, 30: PRINT "5 = Open WIN.INI"

LOCATE 20, 25: COLOR 4: PRINT "<Enter 1,2,3,4,5 or Q to Quit>"
RETURN

example1:
CLS
PRINT " This is the text at example 1"
RETURN

example2:
CLS
PRINT " This is the text at example 2"
RETURN

footer:
LOCATE 20, 30: COLOR 5: PRINT "< M = Menu>"
RETURN


file:
ON ERROR GOTO fileerror
CLS
IF k$ = "3" THEN OPEN "c:\autoexec.bat" FOR INPUT AS #1
IF k$ = "4" THEN OPEN "c:\config.sys" FOR INPUT AS #1
IF k$ = "5" THEN OPEN "c:\windows\win.ini" FOR INPUT AS #1
WHILE NOT EOF(1)
LINE INPUT #1, a$: PRINT a$
WEND
CLOSE 1
RETURN


fileerror:
PRINT "Ooops, there was an error opening a file"
PRINT "Program will restart in 5 seconds"
BEEP
t = TIMER
DO
LOOP UNTIL t + 5 < TIMER
RESUME start

Guest

It depends on the file

Post by Guest » Thu Apr 17, 2003 1:57 pm

It depends on a few things:

1) The file(s) you are using is in pure ASCII format (no pics or special characters [< chr$(32)] )

2) A local printer (not networked)

3) Printer port is LPT1 (not LPT2, USB, nor COMx)

(I'm not certain if escape codes are required but PCLs and PS type printers do sometimes have a problem with printouts.)

If all of the above is true (well, except for PCL/PS types) then you should have no problems opening the files for both viewing and printing through one command. &nbsp;

If you are interested, let me know and I can do a test run and get back to you.

--MiggyD

Post Reply