! 4. day 1-31 for (1,3,7,8,10) to catch 1-32-99

 

 

DO while more data

LET noerror$ = "false"

READ when$

!LET when$ = "1-3-99"

IF when$[1:1]="0" then

PRINT "The month should not begin with '0'"

ELSE IF when$[pos(when$,"-")+1:pos(when$,"-")+1]="0" then

PRINT "The day should not begin with '0'"

ELSE IF val(when$[1:pos(when$,"-")-1])<1 then

PRINT "The month should be between 1 and 12"

ELSE IF val(when$[1:pos(when$,"-")-1])>12 then

PRINT "The month should be between 1 and 12"

ELSE IF val(when$[1:pos(when$,"-")-1]) = 9 and val(when$[pos(when$,"-")+1:posr(when$,"-")-1]) > 30 then

PRINT "September has no more than 30 days"

ELSE IF val(when$[1:pos(when$,"-")-1]) = 4 and val(when$[pos(when$,"-")+1:posr(when$,"-")-1]) > 30 then

PRINT "April has no more than 30 days"

ELSE IF val(when$[1:pos(when$,"-")-1]) = 6 and val(when$[pos(when$,"-")+1:posr(when$,"-")-1]) > 30 then

PRINT "June has no more than 30 days"

ELSE IF val(when$[1:pos(when$,"-")-1]) = 11 and val(when$[pos(when$,"-")+1:posr(when$,"-")-1]) > 30 then

PRINT "November has no more than 30 days"

 

ELSE IF val(when$[pos(when$,"-")+1:posr(when$,"-")-1]) > 31 then

PRINT "No month has no more than 31 days"

 

 

ELSE

PRINT "The date is in correct format"

LET noerror$ = "true"

END IF

PRINT "noerror$ is ..."; noerror$

LOOP

DATA "01-11-11", "1-01-11", "1-11-11", "13-20-85", "11-31-88", "9-31-88" , "1-32-99"

END

The month should not begin with '0'

noerror$ is ...false

The day should not begin with '0'

noerror$ is ...false

The date is in correct format

noerror$ is ...true

The month should be between 1 and 12

noerror$ is ...false

November has no more than 30 days

noerror$ is ...false

September has no more than 30 days

noerror$ is ...false

No month has no more than 31 days

noerror$ is ...false


! now put this coding element into PP6.2