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
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