Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Records
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hskhan




PostPosted: Mon Jun 16, 2003 5:01 pm   Post subject: Records

How would i create / input / output data into a record?
Sponsor
Sponsor
Sponsor
sponsor
PaddyLong




PostPosted: Mon Jun 16, 2003 5:03 pm   Post subject: (No subject)

here is a very simple one that demonstrates what I think you are asking

code:

var person :
    record
        name : string
        age : int
    end record

person.name := "Paddy"
person.age := 17

put person.name, " is ", person.age, " years old"
Andy




PostPosted: Mon Jun 16, 2003 5:14 pm   Post subject: (No subject)

ya you could also create an artifical type like that
type data:
record
name : string
age : int
end record
Andy




PostPosted: Mon Jun 16, 2003 5:14 pm   Post subject: (No subject)

whoa paddylong, you indent even on compsci.ca?
hskhan




PostPosted: Mon Jun 16, 2003 5:21 pm   Post subject: (No subject)

I need a record, and text file combo that checks if a record exists before. how can i check if the record has been added to the text file? Could you please help. Thanks.
So far I have :

code:

type playerRec :
    record
        User : string (5)
        PlayerScore : int
    end record
var rplayer : playerRec

var name : string
put "Name" ..
get name
var getname : string := ""
loop
    if length (name) <= 5 then

        rplayer.User := name
        var fout : int
        open : fout, "outputfile.txt", write, mod, seek
        seek : fout, *
        write : fout, rplayer
        close : fout
        put "Added"
        exit
    end if

end loop
PaddyLong




PostPosted: Mon Jun 16, 2003 6:16 pm   Post subject: (No subject)

dodge_tomahawk wrote:
whoa paddylong, you indent even on compsci.ca?

I type it in turing and press f2 then copy and paste

I would say to read your entire file into an array of records (probably use a flexible array for this) then search through it to check if the data inside it is the same as any of the ones in the array
Andy




PostPosted: Mon Jun 16, 2003 6:17 pm   Post subject: (No subject)

you should take the open satement out of the loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: