• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Checking for a deleted record

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
Roel
 
Would you like to try a free sample? Today we are featuring tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic