Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Checking for a deleted record

Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on the delete room functionality:

When a room is deleted, it is set to "1" or stored as 31 on file.

When I read back the file all the deleted rooms contain "31" in the expected position. When this is converted back the deleted field is 1 except for the last record which is -1. The last record fails my test to check if a room is deleted. However, if I check for the absolute value of deleted, it works fine. It works, but probably for the wrong reasons. I just want to check this is ok and not some dodgy code that will score badly.

I know its the last record, but I'm not reading the whole of the last record only a small portion of it so I wouldn't be expecting a -1 just yet.

This is a portion of my code:

regards, Robert.
Posts: 11604
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Robert,

The length of the deleted flag in my assignment was also 1 byte. I use 0 for a valid record and 1 for a deleted record.

To read the deleted flag I use:

To write the deleted flag I use:

Never experienced a negative number for the deleted flag.

Kind regards,
Whose rules are you playing by? This tiny ad doesn't respect those rules:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic