Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array problem

Status
Not open for further replies.

AMS100

Programmer
Oct 19, 2001
111
GB
The following Array is giving me an error - 'The array must be subscripted. For example Array '

NumberVar Array ST := [1,21,31];
NumberVar Array ND := [2,22];
NumberVar Array RD := [3,23];
NumberVar Array DD := Day({DATAEXAM.APPTSTART});
StringVar DateRem := ToText({DATAEXAM.APPTSTART}, "MMMM")+""+ ToText({DATAEXAM.APPTSTART}, "YYYY");

If DD in ST then ToText(DD,0) + "St" + DateRem else
If DD in ND then ToText (DD,0) + "Nd" + DateRem else
IF DD in RD then ToText (DD,0) + "Rd" + DateRem else
ToText (DD,0) + "Th" + DateRem;

This is my first attempt at an array and I don't know where to start. Basicly its meant to format the day of a date field as '1st', '2nd', '3rd' etc... So if anyone could explain why Im getting this error or any ideas on a better way formating the day it would be much appreciated. thanks
 
AMS,

Good stab. You're virtually 99% there. Only thing is that you're getting an error because your variable DD has been declared as an array, but really isn't one.

Try this:

NumberVar Array ST := [1,21,31];
NumberVar Array ND := [2,22];
NumberVar Array RD := [3,23];
NumberVar DD := Day({DATAEXAM.APPTSTART});
NumberVar YY := Year({DATAEXAM.APPTSTART});

StringVar DateRem := " "+ToText({DATAEXAM.APPTSTART}, "MMMM")+" "+ToText(YY,0);

If DD in ST then ToText(DD,0) + "St" + DateRem else
If DD in ND then ToText (DD,0) + "nd" + DateRem else
IF DD in RD then ToText (DD,0) + "rd" + DateRem else
ToText (DD,0) + "Th" + DateRem;

I've taken the liberty of assigning the year to another variable, because I think as you have it, you might get a literal string of 4 Ys.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top