Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #5791 > unrolled thread
| Started by | Kevin Wells <kev@kevsoft.co.uk> |
|---|---|
| First post | 2019-06-25 18:09 +0100 |
| Last post | 2019-06-27 13:32 +0100 |
| Articles | 11 — 8 participants |
Back to article view | Back to comp.sys.acorn.programmer
Dates as numbers in BASIC Kevin Wells <kev@kevsoft.co.uk> - 2019-06-25 18:09 +0100
Re: Dates as numbers in BASIC "John Williams (News)" <UCEbin@tiscali.co.uk> - 2019-06-25 18:45 +0100
Re: Dates as numbers in BASIC Paul Oates <oatespaul@btinternet.com> - 2019-06-25 19:00 +0100
Re: Dates as numbers in BASIC news@sprow.co.uk - 2019-06-27 05:47 -0700
Re: Dates as numbers in BASIC Kevin Wells <kev@kevsoft.co.uk> - 2019-06-29 12:23 +0100
Re: Dates as numbers in BASIC jgh@mdfs.net - 2019-07-03 11:47 -0700
Re: Dates as numbers in BASIC Harriet Bazley <harriet@bazleyfamily.co.uk> - 2019-06-25 19:25 +0100
Re: Dates as numbers in BASIC Andrew Conroy <a.m.conroy@owlart.co.uk> - 2019-06-26 22:19 +0100
Re: Dates as numbers in BASIC Andrew Conroy <a.m.conroy@owlart.co.uk> - 2019-06-26 23:05 +0100
Re: Dates as numbers in BASIC Alan Adams <alan@adamshome.org.uk> - 2019-06-27 12:08 +0100
Re: Dates as numbers in BASIC Alan Adams <alan@adamshome.org.uk> - 2019-06-27 13:32 +0100
| From | Kevin Wells <kev@kevsoft.co.uk> |
|---|---|
| Date | 2019-06-25 18:09 +0100 |
| Subject | Dates as numbers in BASIC |
| Message-ID | <bbb9c2c957.Kevin@talktalk.net> |
Hi How can you get the month as a number instead of the 3 letter shorterned name e.g? 06 instread of Jun I know I counld do a routine that gets the 3 letter name and convert that to the number equivelent, but that would work on English language computers. Thanks. -- Kev Wells http://kevsoft.co.uk/ carpe cervisium I went into a theatre as sober as could be,
[toc] | [next] | [standalone]
| From | "John Williams (News)" <UCEbin@tiscali.co.uk> |
|---|---|
| Date | 2019-06-25 18:45 +0100 |
| Message-ID | <57c9c60d39UCEbin@tiscali.co.uk> |
| In reply to | #5791 |
In article <bbb9c2c957.Kevin@talktalk.net>, Kevin Wells <kev@kevsoft.co.uk> wrote: > I know I counld do a routine that gets the 3 letter name and convert > that to the number equivelent, but that would work on English language > computers. Yes! But do be careful about spelling! Have someone else check it for you. John -- John Williams, now back in the UK - no attachments to these addresses! Non-RISC OS posters change user to johnrwilliams or put 'risc' in subject! Who is John Williams? http://petit.four.free.fr/picindex/author/
[toc] | [prev] | [next] | [standalone]
| From | Paul Oates <oatespaul@btinternet.com> |
|---|---|
| Date | 2019-06-25 19:00 +0100 |
| Message-ID | <0571c7c957.Paul@oatespaul.btinternet.com> |
| In reply to | #5791 |
I seem to recall there being an OS_Word that dealt with the date & time
format.
In message <bbb9c2c957.Kevin@talktalk.net>
Kevin Wells <kev@kevsoft.co.uk> wrote:
> Hi
> How can you get the month as a number instead of the 3 letter shorterned
> name e.g?
> 06 instread of Jun
> I know I counld do a routine that gets the 3 letter name and convert
> that to the number equivelent, but that would work on English language
> computers.
> Thanks.
--
Paul Oates
oatespaul@btinternet.com
[toc] | [prev] | [next] | [standalone]
| From | news@sprow.co.uk |
|---|---|
| Date | 2019-06-27 05:47 -0700 |
| Message-ID | <e6719fd2-013c-4f2a-8507-8453ca2f3fb1@googlegroups.com> |
| In reply to | #5793 |
> How can you get the month as a number instead of the 3 letter shorterned
> name e.g?
>
> 06 instread of Jun
DIM block 7
?block=1
SYS"OS_Word",14,block
PRINT block?1
If you want it with leading 0 too change the last line to
PRINT RIGHT$("0"+STR$(block?1),2)
Sprow.
[toc] | [prev] | [next] | [standalone]
| From | Kevin Wells <kev@kevsoft.co.uk> |
|---|---|
| Date | 2019-06-29 12:23 +0100 |
| Message-ID | <df5bb2cb57.Kevin@talktalk.net> |
| In reply to | #5799 |
In message <e6719fd2-013c-4f2a-8507-8453ca2f3fb1@googlegroups.com>
news@sprow.co.uk wrote:
>> How can you get the month as a number instead of the 3 letter shorterned
>> name e.g?
>>
>> 06 instread of Jun
>
> DIM block 7
> ?block=1
> SYS"OS_Word",14,block
> PRINT block?1
>
>If you want it with leading 0 too change the last line to
>
> PRINT RIGHT$("0"+STR$(block?1),2)
>
>Sprow.
Thanks that is what is needed. Nice and simple as well.
Thsmkd to all those who gave other answers as well.
--
Kev Wells
http://kevsoft.co.uk/
carpe cervisium
But it's " Saviour of 'is country " when the guns begin to shoot;
[toc] | [prev] | [next] | [standalone]
| From | jgh@mdfs.net |
|---|---|
| Date | 2019-07-03 11:47 -0700 |
| Message-ID | <31f8310a-a5d7-4c46-82a2-2048fa22a354@googlegroups.com> |
| In reply to | #5799 |
sprow wrote: > DIM block 7 > ?block=1 > SYS"OS_Word",14,block > PRINT block?1 Bear in mind that OSWORD 14 returns BCD values, so you will get &01 to &09 and &10 to &12 (16-18). num%=VALSTR$~bcd% will convert it. jgh
[toc] | [prev] | [next] | [standalone]
| From | Harriet Bazley <harriet@bazleyfamily.co.uk> |
|---|---|
| Date | 2019-06-25 19:25 +0100 |
| Message-ID | <0cb5c9c957.harriet@blueyonder.co.uk> |
| In reply to | #5791 |
On 25 Jun 2019 as I do recall,
Kevin Wells wrote:
> Hi
>
> How can you get the month as a number instead of the 3 letter shorterned
> name e.g?
>
> 06 instread of Jun
Use OS_Word 14 to read the computer's clock as a 5-byte time value,
then pass the resulting area of memory to OS_ConvertDateAndTime.
The format string for a three-letter shortened month name is %M3 and for
the month in numbers is %MN - see manuals.
--
Harriet Bazley == Loyaulte me lie ==
You cannot kill time without injuring eternity.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Conroy <a.m.conroy@owlart.co.uk> |
|---|---|
| Date | 2019-06-26 22:19 +0100 |
| Message-ID | <57ca5d74e5a.m.conroy@owlart.co.uk> |
| In reply to | #5794 |
In article <0cb5c9c957.harriet@blueyonder.co.uk>,
Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
> On 25 Jun 2019 as I do recall,
> Kevin Wells wrote:
> > Hi
> >
> > How can you get the month as a number instead of the 3 letter
> > shorterned name e.g?
> >
> > 06 instread of Jun
> Use OS_Word 14 to read the computer's clock as a 5-byte time value,
> then pass the resulting area of memory to OS_ConvertDateAndTime.
> The format string for a three-letter shortened month name is %M3 and for
> the month in numbers is %MN - see manuals.
Or OS_ConvertDateAndTime or, better still,
Territory_ConvertTimeToOrdinals to convert any 5 byte time block rather
than just the current time. You'll then have to parse the result to get
just the month.
Andrew
--
+----------------------------------------+---------------------------------+
| Andrew Conroy, Owl-Art Un-Ltd. | email: a.m.conroy@argonet.co.uk |
| Coming to you on an Acorn RiscPC SA110 | |
+----------------------------------------+---------------------------------+
The impossible I can do at once, miracles take a little longer!!
[toc] | [prev] | [next] | [standalone]
| From | Andrew Conroy <a.m.conroy@owlart.co.uk> |
|---|---|
| Date | 2019-06-26 23:05 +0100 |
| Message-ID | <57ca61b0cda.m.conroy@owlart.co.uk> |
| In reply to | #5795 |
In article <57ca5d74e5a.m.conroy@owlart.co.uk>,
Andrew Conroy <a.m.conroy@owlart.co.uk> wrote:
> In article <0cb5c9c957.harriet@blueyonder.co.uk>,
> Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
> > On 25 Jun 2019 as I do recall,
> > Kevin Wells wrote:
> > > Hi
> > >
> > > How can you get the month as a number instead of the 3 letter
> > > shorterned name e.g?
> > >
> > > 06 instread of Jun
> > Use OS_Word 14 to read the computer's clock as a 5-byte time value,
> > then pass the resulting area of memory to OS_ConvertDateAndTime.
> > The format string for a three-letter shortened month name is %M3 and
> > for the month in numbers is %MN - see manuals.
> Or OS_ConvertDateAndTime or, better still,
> Territory_ConvertTimeToOrdinals to convert any 5 byte time block rather
> than just the current time. You'll then have to parse the result to get
> just the month.
There's also Territory_TimeStringToOrdinals which might be easier. Feed
in a dummy time string with the desired month in it, and back comes the
month number at offset &14 in the buffer.
Andrew
--
+----------------------------------------+---------------------------------+
| Andrew Conroy, Owl-Art Un-Ltd. | email: a.m.conroy@argonet.co.uk |
| Coming to you on an Acorn RiscPC SA110 | |
+----------------------------------------+---------------------------------+
The impossible I can do at once, miracles take a little longer!!
[toc] | [prev] | [next] | [standalone]
| From | Alan Adams <alan@adamshome.org.uk> |
|---|---|
| Date | 2019-06-27 12:08 +0100 |
| Message-ID | <8759a9ca57.Alan.Adams@ArmX6.adamshome.org.uk> |
| In reply to | #5796 |
In message <57ca61b0cda.m.conroy@owlart.co.uk>
Andrew Conroy <a.m.conroy@owlart.co.uk> wrote:
> In article <57ca5d74e5a.m.conroy@owlart.co.uk>,
> Andrew Conroy <a.m.conroy@owlart.co.uk> wrote:
>> In article <0cb5c9c957.harriet@blueyonder.co.uk>,
>> Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
>>> On 25 Jun 2019 as I do recall,
>>> Kevin Wells wrote:
>>>> Hi
>>>>
>>>> How can you get the month as a number instead of the 3 letter
>>>> shorterned name e.g?
>>>>
>>>> 06 instread of Jun
>>> Use OS_Word 14 to read the computer's clock as a 5-byte time value,
>>> then pass the resulting area of memory to OS_ConvertDateAndTime.
>>> The format string for a three-letter shortened month name is %M3 and
>>> for the month in numbers is %MN - see manuals.
>> Or OS_ConvertDateAndTime or, better still,
>> Territory_ConvertTimeToOrdinals to convert any 5 byte time block rather
>> than just the current time. You'll then have to parse the result to get
>> just the month.
> There's also Territory_TimeStringToOrdinals which might be easier. Feed
> in a dummy time string with the desired month in it, and back comes the
> month number at offset &14 in the buffer.
> Andrew
For example:
DIM wlib_block% 256
DEF FNclocktime
=FNclocktime2("%24:%MI:%SE")
DEF FNclocktime2(format$)
LOCAL rsize%,localtime%,result%
IF LEN(format$) > 127 THEN format$=LEFT$(format$,127)
localtime%=wlib_block%
result%=wlib_block%+60
rsize%=128
?localtime%=3
SYS "OS_Word",14,localtime%
SYS "Territory_ConvertDateAndTime",-1,localtime%,result%,rsize%,format$ TO
,rsize%
REM SYS "OS_ConvertDateAndTime",localtime%,result%,rsize%,format$ TO
,rsize%
?rsize%=13
=$result%
For your case:
FNclocktime2("%M3")
will return the current 3-letter month.
--
Alan Adams, from Northamptonshire
alan@adamshome.org.uk
http://www.nckc.org.uk/
[toc] | [prev] | [next] | [standalone]
| From | Alan Adams <alan@adamshome.org.uk> |
|---|---|
| Date | 2019-06-27 13:32 +0100 |
| Message-ID | <5111b1ca57.Alan.Adams@ArmX6.adamshome.org.uk> |
| In reply to | #5797 |
In message <8759a9ca57.Alan.Adams@ArmX6.adamshome.org.uk>
Alan Adams <alan@adamshome.org.uk> wrote:
> In message <57ca61b0cda.m.conroy@owlart.co.uk>
> Andrew Conroy <a.m.conroy@owlart.co.uk> wrote:
>> In article <57ca5d74e5a.m.conroy@owlart.co.uk>,
>> Andrew Conroy <a.m.conroy@owlart.co.uk> wrote:
>>> In article <0cb5c9c957.harriet@blueyonder.co.uk>,
>>> Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
>>>> On 25 Jun 2019 as I do recall,
>>>> Kevin Wells wrote:
>>>>> Hi
>>>>>
>>>>> How can you get the month as a number instead of the 3 letter
>>>>> shorterned name e.g?
>>>>>
>>>>> 06 instread of Jun
>>>> Use OS_Word 14 to read the computer's clock as a 5-byte time value,
>>>> then pass the resulting area of memory to OS_ConvertDateAndTime.
>>>> The format string for a three-letter shortened month name is %M3 and
>>>> for the month in numbers is %MN - see manuals.
>>> Or OS_ConvertDateAndTime or, better still,
>>> Territory_ConvertTimeToOrdinals to convert any 5 byte time block rather
>>> than just the current time. You'll then have to parse the result to get
>>> just the month.
>> There's also Territory_TimeStringToOrdinals which might be easier. Feed
>> in a dummy time string with the desired month in it, and back comes the
>> month number at offset &14 in the buffer.
>> Andrew
> For example:
> DIM wlib_block% 256
> DEF FNclocktime
> =FNclocktime2("%24:%MI:%SE")
> DEF FNclocktime2(format$)
> LOCAL rsize%,localtime%,result%
> IF LEN(format$) > 127 THEN format$=LEFT$(format$,127)
> localtime%=wlib_block%
> result%=wlib_block%+60
> rsize%=128
> ?localtime%=3
> SYS "OS_Word",14,localtime%
> SYS "Territory_ConvertDateAndTime",-1,localtime%,result%,rsize%,format$ TO
> ,rsize%
> REM SYS "OS_ConvertDateAndTime",localtime%,result%,rsize%,format$ TO
> ,rsize%
> ?rsize%=13
> =$result%
> For your case:
> FNclocktime2("%M3")
> will return the current 3-letter month.
while FNclocktime2("%MN") will return the month number, with 01
representing January.
--
Alan Adams, from Northamptonshire
alan@adamshome.org.uk
http://www.nckc.org.uk/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.acorn.programmer
csiph-web