The sequence can be prefixed with a prefix. This prefix could be a chapter number. If no prefix is used, NULL ("") must be passed to the constructor.
For cross referencing, a tag can be passed in to .next(). The tag is is associated with the value. The value can be retrieved.
//Purpose: create a new value in
the sequence (see Sequence object)
function Next(name) {
this.cur++;
if (name != "")
{
this.tag[this.cur]
= name;
}
return (this.pre
+ this.cur);
}
//Purpose: returns the sequence
number for a given tag (see Sequence object)
function GetNum(tag) {
for (var
i = 1; i < this.tag.length; i++) {
if
(tag == this.tag[i]) return(this.pre + i);
}
return (this.pre
+ "?");
}
//-->
</script>
Code | Output |
<script language="JavaScript1.1">
<!-- with (document) { var seq = new Sequence(""); seq.next("");
write("No
prefix<br>");
seq.next("seq2");
write("<br>Prefix
from value in an other sequence<br>");
|
Last Updated: $Date: 2002/03/25 06:35:54 $ GMT ($Revision: 1.5 $)