Re: Custom Data Type
From: John Herbster \(TeamB\) ("John)
Date: 11/09/03
- Next message: Chris Burrows: "Re: Custom Data Type"
- Previous message: Sterling Bates: "ANN: Update to SpiderMonkey interface code"
- In reply to: John Ullom: "Custom Data Type"
- Next in thread: Dr John Stockton: "Re: Custom Data Type"
- Reply: Dr John Stockton: "Re: Custom Data Type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 8 Nov 2003 23:27:34 -0600
"John Ullom" <skygizmo@skygizmo.com> wrote
> I have a procedure that would be more elegant
> if I could create a custom data type.
>
> Here is my data type:
> type TWeekDay = 0..6;
>
> What I was hoping is that for example:
> var vStart : TWeekDay;
>
> begin
> vStart := 5;
> vStart := vStart + 3;
> end;
John, Why not create your own little IncWeekDay
function? Maybe something like this:
Type TWeekDay = 0..6;
function IncWeekDay(Inp: TWeekDay; i: integer): TWeekDay;
var j: integer;
begin
j := (ord(Inp) + i) mod 7; {The ord() is really not needed.}
If (j < 0) {Correct in case i is negative.}
then j := j + 7;
Result := TWeekDay(j); {The cast is really not needed here.}
end; {UNTESTED}
Regards, JohnH
- Next message: Chris Burrows: "Re: Custom Data Type"
- Previous message: Sterling Bates: "ANN: Update to SpiderMonkey interface code"
- In reply to: John Ullom: "Custom Data Type"
- Next in thread: Dr John Stockton: "Re: Custom Data Type"
- Reply: Dr John Stockton: "Re: Custom Data Type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|