1 package C4::Bull; #assumes C4/Bull.pm
4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
24 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
26 # set the version for version checking
31 C4::Bull - Give functions for serializing.
39 Give all XYZ functions
44 @EXPORT = qw(&Initialize_Sequence &Find_Next_Date, &Get_Next_Seq);
46 # FIXME - Retirer ce FIXME il ne sert pas.
54 return $X if ($seq eq 'X');
55 return $Y if ($seq eq 'Y');
56 return $Z if ($seq eq 'Z');
57 return "5 Syntax Error in Sequence";
61 sub Initialize_Sequence(@) {
76 my @string = split //, $sequence;
79 for (my $i = 0; $i < (scalar @string); $i++)
81 if ($string[$i] ne '{')
85 $finalstring .= $string[$i];
89 return "1 Syntax Error in Sequence";
94 # if ($string[$i + 1] eq '\'')
96 # return "2 Syntax Error in Sequence"
97 # if ($string[$i + 2] ne 'X' && $string[$i + 2] ne 'Y' && $string[$i + 2] ne 'Z');
99 # $finalstring .= GetValueAsc($string[$i + 2], $X, $Y, $Z);
104 return "3 Syntax Error in Sequence"
105 if ($string[$i + 1] ne 'X' && $string[$i + 1] ne 'Y' && $string[$i + 1] ne 'Z');
108 $finalstring .= GetValue($string[$i + 1], $X, $Y, $Z);
113 return "$finalstring";
116 sub Find_Next_Date(@) {
138 $X += $Xstep if ($Xstate == 1);
139 if ($Xstate == 2) { $Xpos += 1; if ($Xpos >= $Xfreq) {
140 $Xpos = 0; $X += $Xstep; } }
142 $Y += $Ystep if ($Ystate == 1);
143 if ($Ystate == 2) { $Ypos += 1; if ($Ypos >= $Yfreq) {
144 $Ypos = 0; $Y += $Ystep; } }
146 $Z += $Zstep if ($Zstate == 1);
147 if ($Zstate == 2) { $Zpos += 1; if ($Zpos >= $Zfreq) {
148 $Zpos = 0; $Z += $Zstep; } }
150 # $Y += $Ystep; if ($Ystate == 1);
151 # if ($Ystate == 2) { $Ypos += 1; if ($Ypos >= $Yfreq) {
152 #$Ypos = 0; $Y += $Ystep; } }
155 # $Z += $Zstep; if ($Zstate == 1);
156 # if ($Zstate == 2) { $Zpos += 1; if ($Zpos >= $Zfreq) {
157 # $Zpos = 0; $Z += $Zstep; } }
159 return ($X, $Y, $Z, $Xpos, $Ypos, $Zpos);
162 sub Get_Next_Seq(@) {
163 my $sequence = shift;
180 return ("$sequence", $X, $Y, $Z)
181 if (!defined($X) && !defined($Y) && !defined($Z));
182 ($X, $Y, $Z, $Xpos, $Ypos, $Zpos) =
183 Step($X, $Xstate, $Xfreq, $Xstep, $Y, $Ystate, $Yfreq,
184 $Ystep, $Z, $Zstate, $Zfreq, $Zstep, $Xpos, $Ypos, $Zpos);
185 return (Initialize_Sequence($sequence, $X, $Xstate,
186 $Xfreq, $Xstep, $Y, $Ystate, $Yfreq,
187 $Ystep, $Z, $Zstate, $Zfreq, $Zstep),
188 $X, $Y, $Z, $Xpos, $Ypos, $Zpos);
191 END { } # module clean-up code here (global destructor)