Oxygen Basic

Programming => Problems & Solutions => Topic started by: chrisc on March 12, 2018, 12:30:38 PM

Title: Need a sample prog to write and then read from a random file
Post by: chrisc on March 12, 2018, 12:30:38 PM
Hello all

in PB, we can create random file and then able to retrieve data from it by pointing to an index

i need a sample or example O2 program to show me how to create a random file, write some data with an index
 and then able to read data from it using an index.   Where can i get this program ?

thanxx for any help
Title: Re: Need a sample prog to write and then read from a random file
Post by: Charles Pegge on March 13, 2018, 02:21:56 AM
Hi Chris,

I'll answer it here:
http://www.oxygenbasic.org/forum/index.php?topic=1575.msg17142;topicseen#msg17142
Title: Re: Need a sample prog to write and then read from a random file
Post by: chrisc on March 13, 2018, 07:12:33 AM
Thanxx Charles,  i will check it out
Title: Re: Need a sample prog to write and then read from a random file
Post by: chrisc on March 13, 2018, 10:16:17 AM
Thanxx a lot,  Charles
this is a simple and very good example

but need some explanation for
wchar s[64]

does this means that we define it (the fourth term in the data type) as a 64 characters string?
Title: Re: Need a sample prog to write and then read from a random file
Post by: Charles Pegge on March 13, 2018, 10:59:58 AM
Code: [Select]
'EXAMPLE RECORD
type xyzlabel
  float x,y,z
  wchar s[64]
end type

This is a flat record of 140 bytes

12 bytes for the 3 floats, and 128 bytes for the 64 wide (unicode) characters

I thought a bit of unicode would be trendy :)
Title: Re: Need a sample prog to write and then read from a random file
Post by: chrisc on March 13, 2018, 02:03:13 PM
Yup we need unicode strings