Gossamer Forum
Home : Products : DBMan : Customization :

Re: re: autoincrementing dates

Quote Reply
Re: re: autoincrementing dates In reply to
Thank you for explaining the steps in the code.
I used some of it already. But as I am working with a booking system I must have records 1 year ahead, thus can not compare to &get_date.

I am trying something like this:
-------------
sub get_defaults {
# --------------------------------------------------------
# Returns a hash of the defaults used for a new record.

my (%default);

foreach $field (keys %db_defaults) {
$default{$field} = $db_defaults{$field};
}

if ($db_key_track) {
open (ID, "<$db_id_file_name") or &cgierr("error in get_defaults. unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) { flock(ID, 1); }
need to define $prefix?
$count = substr(<ID>,5)+1;
($count < 100 and 9 < $count ) and ($count = "0$count");
($count < 10) and ($count = "00$count");
if (364 < $count) {$count="001" and $prefix=2000};
$default{$db_key} = "$prefix-$count"; # Get next ID number
close ID;
}
return %default;
}
-----------
I need to set $prefix to the first 4 characters of the <ID> for the start?
($prefix, $count) = unpack("A4 x1 A*", <ID> );
didnt seem to work for me
Subject Author Views Date
Thread re: autoincrementing dates poulR 2560 Jan 28, 1999, 4:39 AM
Post Re: re: autoincrementing dates
poulR 2486 Jan 27, 1999, 9:01 PM
Post Re: re: autoincrementing dates
Lauren Stegman 2490 Jan 28, 1999, 5:11 AM
Post Re: re: autoincrementing dates
poulR 2483 Jan 31, 1999, 3:51 AM