• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB file format - B&S

 
Lara McCarver
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My exam is B&S 2.3.3. I just noticed something odd in the requirements document. It says:
All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field.


And I was just looking at my starting database file, using Textpad in Binary Mode. What I discovered is that in the database that they give you, the fields are space terminated, not null terminated. That is, each of the filler bytes is 0x20.

So... should I use the format I see (space-terminated), or use the format they say (null-terminated)? Either way, this brings up an important question about searches. Suppose that they start out by opening up the sample database. They don't make any changes, but they do a search for "Smallville". According to the instructions, the GUI search is supposed to be an exact search, so... should "Smallville " match?
Edit: this editor won't let me show a string with Smallville followed by 8 spaces. But that is the question. Should "Smallville" with no spaces match "Smallville" followed by 8 spaces?

My inclination would be to document the discrepancy (of course). But then, just leave the database as is (that is, not start out the program by "fixing" the database. However, use null-terminated fields for any database update I make. On a search, allow trailing spaces to match. So "Smallville" and "Smallville" (Edit: followed by 8 spaces) match.

What do you think?

[ May 12, 2005: Message edited by: Lara McCarver ]
[ May 12, 2005: Message edited by: Lara McCarver ]
 
DANNY JI
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is from SUN.
-----------------------------------------------------------------------
We apologize for the error. The fields are space-padded, not null-terminated.
-----------------------------------------------------------------------
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not been notified by SUN of this "error". So I am keeping to my assignment's specification, that is, the strings are to be terminated with a 0 byte if they are shorter than the field width. This would be the case if the customer's legacy application was written in C where strings are zero byte terminated. I also allow for reading such a string.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We've had previous ranchers in this forum email who2contact@sun.com regarding the discrepancy between the instructions and the actual data file provided, and Sun has replied that it is an error (I think Danny's post is a quote from their email... you can find it by searching the forums).

However, when I completed my assignment, I chose to handle both cases (null terminated and space padded) when reading the file, and use null terminated as per the instructions when writing to the file. I also documented it in my choices.txt. This was (apparently) acceptable to Sun (Perfect score in Data class).
 
Titus Barik
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Barry Gaunt:
I have not been notified by SUN of this "error". So I am keeping to my assignment's specification, that is, the strings are to be terminated with a 0 byte if they are shorter than the field width. This would be the case if the customer's legacy application was written in C where strings are zero byte terminated. I also allow for reading such a string.


Doing this will not give you any extra points whatsoever, so why bother? If you're worried because you have't received an official statement from Sun, shoot them an e-mail, and they'll confirm that this is an error.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, in the case when I reported to Sun a problem about the wrong delete flag value in the B&S data file, they sent an email to everyone informing them of the error. They didn't in this case though. Anyway it's been coded, tested, and working for a long time now, so I'm not going to take it out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic