Thanks.

I had tried a similar piece of code myself, based on the fact that
DATE=0 gives 1st January 1961, which (usefully) is a sunday.

Stepping along that first year in units of the number of seconds in a
31 day month (doesn't matter where in the month that    month*31days 
happens
to fall) allows DATE$(month*seconds_per_month) to return a string for
somewhere in that month which allows you to extract the 3 digit month
abbreviation and build up a template string of all the month names.

I can also do the same for day names, again by using the fact that
1/1/1961 is a sunday. So work out the number of seconds per day and
and use DAY$(day*seconds_per_day) to extract the day name:

days$=''
seconds_per_day = 24*60*60
FOR a=0 to 6:days$=days$&DAY$(a*seconds_per_day)

A fairly easy way to extract the language-dependent information for
calendar headings, which is reliable as long as DATE=0 always remains 
at 1/1/1961

Rather late in the day I realised I'd have to make my diary program 
work for the
other language modules allowed by SMSQ/E and wanted to try to find a
way which would work with the currently supported modules (English,
French, German, Italian and Spanish - LANGUAGE=34 is allowed but there
seems to be no module for Spanish). Working as people have suggested
using routines like the above allows future languages to be used too,
as long as DATE=0 always signifies 1/1/1961 as it does on current
machines.

I also liked Francois's method of using a temporary language, although
it wouldn't work in the specific context of my program.

Once again this list has proved its worth to me! The collective
sharing of information and ideas is a brilliant feature of the QL
scene.

-- 
Dilwyn Jones


----- Original Message ----- 
From: "Wolfgang Lenerz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 19, 2006 6:43 AM
Subject: Re: [ql-users] month number


> On 18 Sep 2006 at 17:17, Dilwyn Jones wrote:
>
>> A help request:
>
>
> Hope this helps :
>
>
> DEFine FuNction make_all_months$
> rem this makes a string "JanFeb..." in the current language
> rem this should be called during the initialisation part
> rem eg. all_months$=make_all_months$
> LOCal string$,lp%,a$,temp
>  string$="":a$="":temp=0
>  temp=60*60*24*31
>  FOR lp%=0 TO 11
>    a$=DATE$(lp%*temp)
>    string$=string$&a$(6 TO 8)
>  END FOR lp%
>  RETurn string$
> END DEFine make_all_months$
> :
> DEFine FuNction make_date$(dflag%,what_date)
> rem returns date as "01.01.1991" (dflag%=1) or "1991.01.31"
> (dflag%=0)
> rem if what_date<>0, then it is this date that will be returned
> rem this presumes that a variable "all_month$" exists!
>  LOCal a$,b$,res
>  b$=""
>  IF what_date
>    a$=DATE$(what_date)         : rem make date passed as param into
> string
>  ELSE
>    a$=DATE$                    : rem current date into string
>  END IF
>  b$=a$(6 TO 8)                 : rem 3 letter month abbreviation
>  res= b$ INSTR all_months$             : rem find it
>  IF NOT res
>       all_months$=make_all_months$     : rem not found?, make
> all_month$
>       res= b$ INSTR all_months$        : rem and retry
>  END IF
>  res=(res+2)/3                 : rem this is the month in figures
>  b$=res:IF res<10:b$="0"&b$            : rem add leading 0 if
> necessary
>  IF dflag%:RETurn a$(10 TO 11)&"."&b$&"."&a$(1 TO 4)
>  RETurn a$(1 TO 4)&"."&b$&"."&a$(10 TO 11)
> END DEFine make_date$
> :
> Should be self eplanatory.
>
> Wolfgang
> -- 
> W. H. Lenerz
> www.scp-paulet-lenerz.com
> -- 
> _______________________________________________
> QL-Users Mailing List
> http://www.q-v-d.demon.co.uk/smsqe.htm
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date:
> 14/09/2006
>
>



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: 14/09/2006

_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to