what does this mean?!?!

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
babygodzilla

what does this mean?!?!

Post by babygodzilla »

hello all. can u help me?

what does the following code do?

Code: Select all

DIM Q(200)
IF popnum = 1 THEN GOSUB open1

.....



open1:
OPEN "R", #1, "onepop.dat", 4
FIELD #1, 4 AS F.pop$:RETURN
all i can see is it opens a file, and then what?
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Babygodzilla, hmmm....

Umm...I never seen OPEN used like that, just like this:
OPEN "location of file" FOR put OUTPUT, APPEND or INPUT here AS #1

Well I can't help you, but good name though.....GOSUB? :P

No comment on that PLEASE.
"But...It was so beutifully done"
Guest

Post by Guest »

i dunno this is from an old old OLD Mac (it's black and white...) and I'm supposed to port it to Flash, cept i dont think this prog works so I have no idea ??? its supposed to do. i think the problem lies within the opening of that file... i dunno... :roll:
babygodzilla

Post by babygodzilla »

what does "AS #1" do?
Agent_Firestalker

as #1... explained

Post by Agent_Firestalker »

it tells qb that you are opening a file and to store that file temporarily as number 1. you can then use #1 instead of the file name.

Agent_Firestalker
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

What you're looking at is an alternate OPEN technique, a sort of OPEN shorthand. In addition, it's opening the file in a rarely-used-anymore mode called RANDOM. After that, the FIELD statement is used to allocate space for RANDOM-mode data. The 4's are the size, in bytes, of the data requested. It's a very convulted method that's been long replaced with BINARY mode.
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Ooohh...So this is the Random-access stuff I keep hearing about?

BTW AS #1 makes that file #1 it like a reference variable for functions to reference later:

For example:

IF EOF(1) = -1 then EXIT DO

will exit a do loop if the position of the file reader is at the end of the file that was opened as #1.
"But...It was so beutifully done"
babygodzilla

Post by babygodzilla »

Nekrophidius wrote:What you're looking at is an alternate OPEN technique, a sort of OPEN shorthand. In addition, it's opening the file in a rarely-used-anymore mode called RANDOM. After that, the FIELD statement is used to allocate space for RANDOM-mode data. The 4's are the size, in bytes, of the data requested. It's a very convulted method that's been long replaced with BINARY mode.

so, assuming there are values in the file, should that value be saved in F.pop$?



thanks!
Post Reply