Random access files with fixed-length string

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Random access files with fixed-length string

Gian
Hello everyone,
those coming from the Windows VB, frequently asks how to work with
random access files with fixed-length string.
I created this demo as an explanation and would like to know if you
think right, correct in part or completely wrong.
Thank you for attention

Gianluigi

Attention: This application contains a Spinner, you need version => 3.6
Create a directory with the name of the application in user.home to save
file dat.

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user

Random&FixedString-en-0.0.1.tar.gz (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Random access files with fixed-length string

Gian
Il 10/03/2015 22:00, Gian ha scritto:

> Hello everyone,
> those coming from the Windows VB, frequently asks how to work with
> random access files with fixed-length string.
> I created this demo as an explanation and would like to know if you
> think right, correct in part or completely wrong.
> Thank you for attention
>
> Gianluigi
>
> Attention: This application contains a Spinner, you need version => 3.6
> Create a directory with the name of the application in user.home to save
> file dat.
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
>
>
>
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>

Hi,
re-reading what I wrote in my terrible English, it seems that you have
to create a directory.
Instead I wanted to let you know that the program creates a directory,
is perhaps more rightly so:
Attention:
This application contains a Spinner, you need version => 3.6 and creates
a directory with the name of the application in user.home to save file dat.

Regards
Gianluigi

P.S. It cost me so much effort, do you think someone will answer me?

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: Random access files with fixed-length string

Tobias Boege-2
In reply to this post by Gian
On Tue, 10 Mar 2015, Gian wrote:
> Hello everyone,
> those coming from the Windows VB, frequently asks how to work with random
> access files with fixed-length string.
> I created this demo as an explanation and would like to know if you think
> right, correct in part or completely wrong.
> Thank you for attention
>

Looks good. But, as you mentioned in the project description, it would also
be possible, and easier, to use Structs, as we did[0].

Also, if someone came to me and said: "in VB I used to store data in a non-
human-readable binary format. I want to continue doing so", I would briefly
mention that this is not *necessarily* a nice move and plain text files are
much more welcome in general. Also, if you are GNU-affine, they say[1]:

  "[...] Unix programs often have static tables or fixed-size strings, which
   make for arbitrary limits; use dynamic allocation instead."

If you create a new file format for your application, there are gb.settings
and gb.xml to consider first which provide these things already.

Regards,
Tobi

[0] http://gambaswiki.org/wiki/app/struct-db
[1] https://www.gnu.org/prep/standards/html_node/Reading-Non_002dFree-Code.html#Reading-Non_002dFree-Code

--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: Random access files with fixed-length string

Gian
Il 11/03/2015 14:12, Tobias Boege ha scritto:
> On Tue, 10 Mar 2015, Gian wrote:
>> Hello everyone,
>> those coming from the Windows VB, frequently asks how to work with random
>> access files with fixed-length string.
>> I created this demo as an explanation and would like to know if you think
>> right, correct in part or completely wrong.
>> Thank you for attention
>>
>

Hello Tobias,
I would like to clarify this:
My example comes from a discussion of the Italian forum where some said
that in Gambas there is no concept of random with fixed-length strings.
I counseled the use of a database. :)

> Looks good. But, as you mentioned in the project description, it would also
> be possible, and easier, to use Structs, as we did[0].
>

This I was already said, but I do not understand what it would be easier
in my example using the structure.
If the structure add a fixed array as you can have dynamism?
How can you change the single data in the record, without changing the
whole file?

> Also, if someone came to me and said: "in VB I used to store data in a non-
> human-readable binary format. I want to continue doing so", I would briefly
> mention that this is not *necessarily* a nice move and plain text files are
> much more welcome in general. Also, if you are GNU-affine, they say[1]:
>
>    "[...] Unix programs often have static tables or fixed-size strings, which
>     make for arbitrary limits; use dynamic allocation instead."
>
> If you create a new file format for your application, there are gb.settings
> and gb.xml to consider first which provide these things already.

I agree but I think a database is better :)

Thank you very much
Gianluigi



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: Random access files with fixed-length string

Gian
In reply to this post by Tobias Boege-2
Il 11/03/2015 14:12, Tobias Boege ha scritto:

> Looks good. But, as you mentioned in the project description, it would also
> be possible, and easier, to use Structs, as we did[0].

> [0] http://gambaswiki.org/wiki/app/struct-db

Great Tobias,
perhaps beginning to see the light. :)
I continue to study ... then I tell you.
Regards
Gianluigi

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: Random access files with fixed-length string

Gian
Il 12/03/2015 11:10, Gian ha scritto:

> Il 11/03/2015 14:12, Tobias Boege ha scritto:
>
>> Looks good. But, as you mentioned in the project description, it would also
>> be possible, and easier, to use Structs, as we did[0].
>
>> [0] http://gambaswiki.org/wiki/app/struct-db
>
> Great Tobias,
> perhaps beginning to see the light. :)
> I continue to study ... then I tell you.
> Regards
> Gianluigi
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
Hello Tobias,
I attach a new version of Random access to files based on what you
suggested me.
I hope that well understand. What do you think, will come promoted or
not?  :)
About gb.settings and gb.xml unfortunately I did not understand what you
suggest me, perhaps to use their instead of the dat file? But how?

Regards
Gianluigi

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user

MyStruct-DB-0.0.tar.gz (11K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Random access files with fixed-length string

Tobias Boege-2
On Mon, 16 Mar 2015, Gian wrote:
> About gb.settings and gb.xml unfortunately I did not understand what you
> suggest me, perhaps to use their instead of the dat file? But how?
>

If you are creating a new file format for your application, you should,
when possible, refrain from using a binary format with string size
limitations. That's the premise.

Instead use gb.settings which is capable of formatting values in native
datatypes (Integer, Float, String, ...) and even arrays and collections
of them as human-readable, non-limited strings. If there is a scenario
where a human might legitimately want to look at the data file of your
application, you should make it human-readable. gb.settings also allows
to structure the data slightly into "slots".

Regards,
Tobi

--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user