- Meino Christian Cramer wrote:
> From: Thomas Hundt <thundt@...>

&mid $time 9 1 is the MSB of the day ("D") not month ("M") in

> Subject: Re: [jasspa] How can I insert a time mark

> Date: Mon, 23 May 2005 10:04:20 -0700

>

> Hi Thomas!

>

> Short question to one line of your macro:

>

> The line

> insert-string &add 0 &mid $time 9 1 ; make space into '0'

> inserts a "0" to make a "05" of the " 5"...but what happens if

> it is Christmas? Will I get "02" from "12" then? Or i sthere any

> magic I currently do not understand?

YYYYCCCMMDD. Character 0 is the first character in &mid i.e.

&mid 0 1 = "Y"

&mid 1 1 = "Y"

&mid 2 1 = "Y"

&mid 3 1 = "Y"

&mid 4 1 = "C"

&mid 5 1 = "C"

&mid 6 1 = "C"

&mid 7 1 = "M"

&mid 8 1 = "M"

&mid 9 1 = "D"

&mid 10 1 = "D"

etc.

Also note

&mid 0 4 = "YYYY"

&mid 4 3 = "CCC"

&mid 7 2 = "MM"

&mid 9 2 = "DD"

>

Thomas has been rather clever here. Using &add then he has basically

> (NO! cristism...I am only curious whether I understand the code right...)

>

turned a character into a number. &add is a math operation therefore

will only accept digits, if you give it a letter then you get 0 (or

FALSE). To understand this then put the following in your *scratch*

buffer and execute it (M-x execute-buffer):-

2000 ml-write &spr "%d" "a"

What you get one the mode line is '0' because %d wants a digit and has

got an 'a' which is tuned into zero. So going back to your question....

If "&mid $time 9 1" == " " (space) then you get

&add 0 " "

which is "0"

If "&mid $time 9 1" == "1" then you get

&add 0 "1"

which is "1"

Very nice - probably why he added the comment to point out this trick.

To play with &mid in *scratch* could execute the following (DD is the

result):-

2000 ml-write &spr "%s" &mid "YYYYCCCMMDD" 9 2

Jon.> Keep microemacsing!

> Meino - From: Jon Green <jnaught@...>

Subject: Re: [jasspa] How can I insert a time mark

Date: Mon, 23 May 2005 19:35:01 +0100

Hi Jon,

Thanky A LOT for this explanations!

Thats clarifies much...

Have a nice day!

Keep microemacsing! :)

Meino

> Meino Christian Cramer wrote:

> > From: Thomas Hundt <thundt@...>

> > Subject: Re: [jasspa] How can I insert a time mark

> > Date: Mon, 23 May 2005 10:04:20 -0700

> >

> > Hi Thomas!

> >

> > Short question to one line of your macro:

> >

> > The line

> > insert-string &add 0 &mid $time 9 1 ; make space into '0'

> > inserts a "0" to make a "05" of the " 5"...but what happens if

> > it is Christmas? Will I get "02" from "12" then? Or i sthere any

> > magic I currently do not understand?

>

> &mid $time 9 1 is the MSB of the day ("D") not month ("M") in

> YYYYCCCMMDD. Character 0 is the first character in &mid i.e.

>

> &mid 0 1 = "Y"

> &mid 1 1 = "Y"

> &mid 2 1 = "Y"

> &mid 3 1 = "Y"

> &mid 4 1 = "C"

> &mid 5 1 = "C"

> &mid 6 1 = "C"

> &mid 7 1 = "M"

> &mid 8 1 = "M"

> &mid 9 1 = "D"

> &mid 10 1 = "D"

> etc.

>

> Also note

>

> &mid 0 4 = "YYYY"

> &mid 4 3 = "CCC"

> &mid 7 2 = "MM"

> &mid 9 2 = "DD"

>

> >

> > (NO! cristism...I am only curious whether I understand the code right...)

> >

>

> Thomas has been rather clever here. Using &add then he has basically

> turned a character into a number. &add is a math operation therefore

> will only accept digits, if you give it a letter then you get 0 (or

> FALSE). To understand this then put the following in your *scratch*

> buffer and execute it (M-x execute-buffer):-

>

> 2000 ml-write &spr "%d" "a"

>

> What you get one the mode line is '0' because %d wants a digit and has

> got an 'a' which is tuned into zero. So going back to your question....

>

> If "&mid $time 9 1" == " " (space) then you get

>

> &add 0 " "

>

> which is "0"

>

> If "&mid $time 9 1" == "1" then you get

>

> &add 0 "1"

>

> which is "1"

>

> Very nice - probably why he added the comment to point out this trick.

>

>

>

> To play with &mid in *scratch* could execute the following (DD is the

> result):-

>

> 2000 ml-write &spr "%s" &mid "YYYYCCCMMDD" 9 2

>

>

> Jon.

> > Keep microemacsing!

> > Meino

>

>

> __________________________________________________________________________

>

> This is an unmoderated list. JASSPA is not responsible for the content of

> any material posted to this list.

>

> To unsubscribe, send a mail message to

>

> mailto:jasspa-unsubscribe@yahoogroups.com

>

> or visit http://groups.yahoo.com/group/jasspa and

> modify your account settings manually.

>

>

>

> Yahoo! Groups Links

>

>

>

>

>

>