sigh...its a BIG'un

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

sigh...its a BIG'un

Post by sid6.7 »

been pounding my head on my screen can no longer see for the blood...

input,output,append,get,put,random,print,write.....yeesh
having a heck of a time getting this to work...

i have a text file with text in it:
blah
bloo
bleep
...

i want to put it in a record file and add a record number to it...
1 blah
2 bloo
3 bleep
...

then i want my user to enter a number of times he wants it to go thru the whole thing...

then i want to make a random number ....int(rnd * 50)
read my record file
compare the random to the record number if equal make NEW file
with a NEW record number.
1 bleep
2 blah
3 bloo
...
if they are not equal go get another record to look at...

i've gotten numerous results in all steps and alot of explosions
you should see my den... :( its seems if get works put doesnt
if input works print doesnt or any combination...

any ideas what to do or what i am doing wrong?

try not to laugh to hard....im bleeding profusely from many wounds...
User avatar
Deleter
Veteran
Posts: 119
Joined: Sat May 07, 2005 7:31 pm

Post by Deleter »

without any code its impossible to say. I don't get what you mean when you say
sid6.7 wrote:then i want my user to enter a number of times he wants it to go thru the whole thing...

then i want to make a random number ....int(rnd * 50)
read my record file
compare the random to the record number if equal make NEW file
with a NEW record number.
perhaps if you explained better I'd be able to help you.
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 »

some code huh...ignore variable names as i'm just putting in
readable stuff...so to speak...

type record
num as integer
text as string * X
end type

dim r as record

type data
text as string * x
end type

dim d as data

' make data file from a text file
------------------------------------
open textfile for input as #1
open data for random as #2

do
input #1, d.text <<< getting text file info
let xy = xy +1 <make a record number for it
let r.num = xy
let r.text = d.text
put #2, r.num, r.text <<<putting it into data file

loop until eof(1)
close #1, #2

open data for random as #1
open final for append as #2

'get user to input a number for looping...
-----------------------------------------------
input "make a number"; number

for cntr = 1 to number

randomnum = int(rnd *50) <<< as there are 50 lines in data file
get #1, randomnum,r.text <<< using random instead of r.num?
let usernum = usernum +1
print#2, usernum,r.text << print to final with NEW rec number?

next cntr

let r.text = "copyrights notice"
print#2, r.text

close #1, #2
print "have a nice day"

hows that?
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

revison partially works

Post by sid6.7 »

okay i got it to partially work finally
but now it cuts off part of the data...


1 een is Killed
2 ight Light in Sky
3 ssesion
4 een is born
5 arm of Locust
6 mine
7 on turns Color
8 ce Wars
9 ng is Killed
10 een dies

i have a data file
a record file
and a final file

when i make the record file it does something wierd too
it puts the data accross rather then down...IE

data
blah
bloo
blee

record
blah bloo blee

here is the code...where is the error...?

CLS
RANDOMIZE TIMER

' define variables

TYPE infile
event AS STRING * 25
END TYPE

TYPE outfile
num AS INTEGER
eve AS STRING * 25
END TYPE

TYPE final
nm AS INTEGER
ev AS STRING * 25
END TYPE


DIM i AS infile
DIM o AS outfile
DIM f AS final

x = 0
year = 0
yeer = 0
cntr = 0
mrkr = 0

' now we open infile and make the outfile

outfile.make:

OPEN "c:\wtools\data.fil" FOR INPUT AS #1
OPEN "c:\wtools\rec.fil" FOR RANDOM AS #2 LEN = LEN(o)


DO

INPUT #1, i.event
LET x = x + 1
LET o.num = x
LET o.eve = i.event
PUT #2, o.num, o.eve

LOOP UNTIL EOF(1)
CLOSE #1
CLOSE #2

' now we open outfile compare to random number
' then make history file with a year number

CLS

dome:

OPEN "c:\wtools\rec.fil" FOR RANDOM AS #3 LEN = LEN(o)
OPEN "c:\wtools\hist.txt" FOR OUTPUT AS #4

INPUT "Please enter number :"; year


FOR cntr = 1 TO year


mrkr = INT(RND * 50) + 1
PRINT mrkr <<<<<<<< < just to see its working
SLEEP 1
GET #3, mrkr, o
LET yeer = yeer + 1 <<<<<<< set new record number
LET f.nm = yeer
LET f.ev = o.eve
PRINT #4, f.nm, f.ev <<<< print to final file


NEXT cntr
CLOSE #3
CLOSE #4
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

other note

Post by sid6.7 »

it seems to kill the first 2 letters of the text feild....
Post Reply