Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Does c++ have an equivalent function to READ and DATA?

Author
Message
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 3rd Mar 2008 01:37
I need to create some test points (x,y,z). Store them in a structure. Does c++ have an equivalent function to READ and DATA?

Thanks in Advance

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
Posted: 3rd Mar 2008 04:13
Yes it does, but it's a bit more complicated. Though from what I have heard structures and class's work a bit better.

here's something you might be able to use..

Take a look at the "Documentation" help file. Look into the "file" catagory. Some noted commands are...

int dbFileOpen ( int iFile )

dbOpenToRead ( int iFile, char* szFilename )

void dbWriteFile ( int iFile, int iVariable )

void dbReadFile ( int iFile, int iVariable )

void dbCloseFile ( int iFile )

Hope that helps out..

There are many answers but just one question" ~ Jerilith the Mad
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 3rd Mar 2008 04:32
@Timidon

Thanks for your input but I really wanted something to simply stick at the end of a file so that I could easily manipulate the values rather that have an external text file. I am currently stuffing the data I need into the structure using an initializing function but the old READ was a handy way to keep DATA internal.

I might use a temparray to stuff the data inline then loop to fill the array

Thanks anyway

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 3rd Mar 2008 04:47 Edited at: 3rd Mar 2008 04:49
You can use arrays and initialize the array when you declare it. For example:


to read the value in the array element you subscript, like:



which gives you the fifth element (loved that movie) of the array and assigns it to i.

You could use a variable for the index if you needed to read in a loop.

In order to group your points you could use three separate arrays with the x, y and z values in each one or create a structure.



To create an array of these and initialize them in triads you'd do something like



You can also initialize them without the inside curly braces but putting the braces in helps to keep things straight for you. You would address the x, y and z values thus:



Where i is your index into the list. I believe that more recent incarnations of the c/c++ language would automatically make "points" a new data type and you really wouldn't need to place the keyword "struct" in front of points when declaring an instance of points.

You can also mix data type within a structure, including character arrays and character pointers.



Lilith, Night Butterfly
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 3rd Mar 2008 05:19
@Lilith

That is exactly what I was looking for a small modification on your idea would be



this should allow me to easily modify the test values on the fly

Thanks

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 3rd Mar 2008 05:33
True dat. The alignment isn't relevant as long as your data is in order.

Oh, and if you're doing points that vary in how many you need to test and you're using a loop you can determine how many elements you have by doing something like



That way you can add or remove points without having to change the limits on your index.

Lilith, Night Butterfly
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 3rd Mar 2008 20:54
Codger - I do that technique to hardcode an image i use in many tests I do during development. works well. I have in my init a little loop where a little 32x32 image is created in mem memblock - then I can use it anywhere.

Definately one of the limited options for inlining media.

Login to post a reply

Server time is: 2024-11-17 07:04:37
Your offset time is: 2024-11-17 07:04:37