Re: Custom Data Type

From: John Herbster \(TeamB\) ("John)
Date: 11/09/03


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



Relevant Pages

  • Re: Max value of data type [comp.lang.c.moderated]
    ... that can be represented by AEI_unit data type. ... elegant way to do this? ... Remove del for email ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • Re: Max value of data type [comp.lang.c.moderated]
    ... that can be represented by AEI_unit data type. ... elegant way to do this? ... have an appropriate newsgroups line in your header for your mail to be seen, ... or the newsgroup name in square brackets in the subject line. ...
    (comp.lang.c.moderated)
  • Re: Custom data type
    ... > I would like to create a custom data type (or whatever the ... > terminology is) when I am designing my fields within design view. ... > where autonumber is an incrementing number that starts at "0" and ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Sharepoint Columns Questions
    ... the uncheck the Display boxes for the columns ... I don't think you can make a custom data type. ...
    (microsoft.public.sharepoint.windowsservices)
  • How to custom data type in patter search
    ... I am using the pattern search toolbox in Matlab 2007a. ... I want to set the decison variable integer. ... I find some demos for custom data type for GA and simulated annealing. ...
    (comp.soft-sys.matlab)