|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Topic # 1250 |
How does reading of .pdb work |
12/08/2005 @ 10:14 by Az Moghal
|
Hi Laurent,
Need to ask question which to you BASIC developers is probably very trivial.
In this code snippet below from IBAddress_ibas.txt can you explain how the record is being split into its constituent field values as there doesn't seem to be any incremental loop or field delimiters involved. It seems to magicaly assign field to string variable before doing print, how does it know start/end of each field and size in record?
_W1Now: OPEN "iBAddrDB" FOR RANDOM AS #1 J=I-1*7+1 SEEK #1,J PRINT #1,N PRINT #1,A$ : PRINT #1,B$ PRINT #1,C$ : PRINT #1,D$ PRINT #1,E$ : PRINT #1,F$ CLOSE #1 RETURN
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 1 -------- 12/08/2005 @ 13:39 by Khertan
visitor |
It's very simple ... for each print you create a new record ...
And for each INPUT you read the record and the next input will read the next record... |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 2 -------- 12/08/2005 @ 13:46 by aldweb
visitor |
Hello Az,
This routine W1Now = Write ONE Record Now only writes one record. A record is a set of 7 fields, each containing a single information as defined for one person in iBAddress' main form.
This routine is called for each single writing operation in the database, passing the values required: - I which is a number telling which record to write - N, A$ to F$ containing the 7 fields' information
In the iBAddress database, all records are made of 7 fields which are stacked. So, if you have created 3 persons, 21 fields will be stored in the database, record 1 starting at position 1, record 2 starting at position 8, record 3 starting at position 15.
Then, if we look back at this routine in details. First, J is calculated to point to the first field of a record. As we are in PARSER OFF mode, here is what it really calculated: J=(I-1)*7+1 If I=1 then J=1 If I=2 then J=8 If I=3 then J=15 The SEEK instruction then jumps to that field in the opened database. The following 7 PRINT instructions replace each single field value in the database (for existing fields) or adds them on top of the database (for a new record). Indeed, the PRINT instruction writes in a given position in a file and then increments the position in the file to the next field, as explained in the documentation.
I hope these explanations clarify your understanding
Cheers
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 3 -------- 12/08/2005 @ 13:50 by aldweb
visitor |
Yups, Khertan and myself did not use the word "record" in the same way, and Khertan has the right use!
A "file record" is what I called a "field" in my explanations. What I called a "record" was, let's say, a "person record" made of 7 informations or "fields", and thus being a set of 7 "file record".
I am pretty sure I confused everyone, including myself, with the previous sentence!
Cheers
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 4 -------- 12/08/2005 @ 14:01 by Az Moghal
visitor |
Thanks Guys..
I appreciate the quick response
Regards
Az Moghal |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 5 -------- 12/08/2005 @ 18:16 by Khertan
visitor |
Just for information, i think using 7 record s for 7 field is not very clean ... in a most way doing only one record containing the seven field is better. You can do that by concatenated the field with a separator character and when reading parsing the record to separate field with the character.
It s just a comment on the iBAdress example.
(If you want a example of what i m trying to explain, just ask me, i ll give you) |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 6 -------- 12/08/2005 @ 18:41 by aldweb
visitor |
You are very right Khertan The MegaString is especially well suited for doing so But at the time I wrote this sample program, the MegaString had not been implemented yet
Cheers
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 7 -------- 13/08/2005 @ 22:18 by apdi2003
visitor |
La réponse dépend toujours un peu de la question qu'on se pose. Khertan a surement raison pour optimiser la taille des fichiers, par contre la présentation des enregistrements triés suivant les différents champs d'information (qui est une des visées pédagogiques de iBadress) n'est pas du tout facilitée. Et la création/maintenance de fichiers d'index n'a rien de basique.
apdi2003 |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 8 -------- 13/08/2005 @ 23:36 by aldweb
visitor |
Oui, Khertan a raison pour optimiser la taille des fichiers sur ces nouveaux modèles de Palm qui fonctionnent en réservant des clusters de plusieurs Ko pour chaque enregistrement alors que les Palms "traditionnels" mappaient chaque octet employé. C'est ce qui a été massivement reproché aux T5 et Tréo650 lors de leur sortie, les fichiers prenant un embonpoint envahissant...
Et, ce n'est pas si compliqué que ça d'aligner toutes les données dans un seul enregistrement, avec un séparateur, puis de relire ainsi chaque enregistrement. C'est ce que je fais pour les piles initiales de nombres et de textes dans iziBasic (voir les ressources iBas 1 et iBas 31 dans un programme compilé par iziBasic)
Maintenant, apdi2003, tu as raison aussi, la méthode pédagogique utilisée dans iBAddress est aussi valable, surtout pour les Palms "traditionnels" car il n'y a alors aucun gachi d'espace mémoire pour des routines de lecture/écriture des enregistrements un peu plus simples à écrire.
Mon prochain projet, c'est un scoop, actuellement en fin de codage, que j'ai appelé ViziBasic (pour Visual editor pour iziBasic, bref un environnement complet de développement d'applications GUI avec génération de code iziBasic automatisé) fonctionnera sur un principe similaire à iBAddress, la MegaString étant utilisée par ailleurs pour générer un DOC code source compilable par iziBasic.
@+ aldweb |
|
|
topic active
topic closed
Sticky
New message -
Correct message
Close topic
Make sticky
|
|