----------------------------------- rk_rkade Mon Apr 12, 2004 6:31 pm Records ----------------------------------- :wink: :oops: hey guys.... umm im kinda embaressed to say this but i'm a newb, and i have no dam clue on how to make and edit a record.... i read dodge_tomahawk's tutorial, but i ran it and it didn't ask me to input anything :? .... i want to be able to input names, addresses, telephone #s, etc. so i kinda need help desperately :shock: .... i'd appriciate it if anyone can explain it to me.... thanks :D ----------------------------------- Tony Mon Apr 12, 2004 7:00 pm ----------------------------------- well records are used to group a number of variables into a group to create types. Such as a 2D point type will contain both X and Y coordinates of the point rether then having 2 separate variables. type person: record name:string age:int end record var me:person me.name := "tony" me.age := 18 here instead having to declear separate variables for name and age, a record is created to hold both. A variable is decleared to be of that type and contains every variable field inside of itself. records are usually used in conjunction with arrays ----------------------------------- EDEN-E Mon Apr 12, 2004 10:37 pm or ----------------------------------- or you can declare variable like following without 'type' var me: record name:string age:int end record me.name := "edne-e" me.age := 16 put me.name put me.age ----------------------------------- rk_rkade Thu Apr 15, 2004 5:52 pm ----------------------------------- :D :) :D :) :D :) YAY! thanks a lot guys.....but, how can i type the name/age as a variable instead of a constant? and also, how can i save it in a text file?? :oops: :oops: :oops: thanx again guys.... ----------------------------------- AsianSensation Thu Apr 15, 2004 6:30 pm ----------------------------------- like you would save any other string. type SomeType : record X, Y : real; Clr : int; end record; var Object: SomeType; Object.X := 5.6; Object.Y := 6.7; Object.Clr := 4; var fileout : int; open: fileout, "something.txt", put; put: fileout, Object.X; put: fileout, Object.Y; put: fileout, Object.Clr; to get, just get it in the same fashion as normal textfiles. But make sure you get it in the same format when you declared the structure. ----------------------------------- rk_rkade Sun Apr 18, 2004 1:06 pm ----------------------------------- aah....thanks a lot AsianSensation....you answered everything that i wanted to kno.... :D! ----------------------------------- the_short1 Sun Apr 18, 2004 4:43 pm ----------------------------------- that was a question from the gr.10 turing book.. "make a program using record's that asks the user for age,name,adress, then display it" sound familiar.... its ok RK_RK..... ;) ur better then most ppl that come here for help.... some just say the question from the book and tell us to do it.. u were genuinely needing the help, and u were atempting it.... good job... ur not 'one of them' **the anoying ppl that just ask us for the answers.... here is 3 bits... and i hope u become an active member of this forum :D ----------------------------------- rk_rkade Wed Apr 21, 2004 5:54 pm ----------------------------------- YAY! thanks short1 :D ...i'll try to b as active as i can 8) ----------------------------------- gamer Wed Apr 21, 2004 5:58 pm ----------------------------------- sry but little confusing for me.....but i will still try it...thnx forhelp ----------------------------------- TheZsterBunny Sun Apr 25, 2004 3:16 pm ----------------------------------- how can one read entire records from a file? and for that matter, write them. and is it possible to have arrays within the records? -bunny (read/write not get/put) ----------------------------------- Cervantes Sun Apr 25, 2004 4:14 pm ----------------------------------- yeah you can have arrays within the records. you just do it. :) type sometype : record x, y, Clr : array 1 .. 100 of int end record var object : sometype for i : 1 .. 100 object.x (i) := Rand.Int (0, maxx) object.y (i) := Rand.Int (0, maxy) object.Clr (i) := Rand.Int (1, 255) end for for d : 1 .. 100 drawfilloval (object.x (d), object.y (d), 4, 4, object.Clr (d)) end for EDIT: One thing you can't do to the best of my knowledge in the current version of turing is use flexible arrays in records. You get a syntax error. :evil: ----------------------------------- the_short1 Sun Apr 25, 2004 6:23 pm ----------------------------------- yea... records are great for mass amounts of stuff... see their use in Asian Sensation's and Mazer's SNOWFALL program in source code.. cuz it needed x,y, and direction, and size.... and it works VERY well.. .... now i want to make something as good as that snowfall.. :( ?: WHAT IS A FLEXIBLE ARRAY?? ----------------------------------- TheZsterBunny Sun Apr 25, 2004 6:43 pm ----------------------------------- a flexible array is an array which must be 1d, but can change size. ex. var flexon :flexible array 1..0 of int new flexon, 50 flexon is now an array from 1..50 this can be used in animation where you don't always have to have so many, but the number can change. -bunny oh, and flexon(r) is wholly owned by someone, so i can't use the name. [/code] ----------------------------------- TheZsterBunny Sun Apr 25, 2004 7:15 pm ----------------------------------- The problem i'm having with records are writing them to files. I'll attach my problem. this is supposed to help design levels for my game. it is still in the process of being made (the code is disorderly, and the program sucks) but i cannot seem to get this program to write full records. my record has an array, a string, and an integer. all 3 are initialized, but only the string is put. Why is this