- Hi Flo,

You have are right in what the hex conversion was supposed to do.

In the mean time I found my original char to hex clip, which only converted a single digit. I applied the single-digit approach to your problem. While I got it to work, it just raised another problem.

The alphabet is like a base-26 number set (English aplhabet), after shifting a to zero. Straight conversion to numbers creates gaps, where it rolls to the next digit, i.e. aaz --> aba has a gap of 26!, the value of the next digit, and azz to baa has a gap much larger!

I believe you already had a base-26 suggestion. But I was on a roll and created my own version, looking at two ideas:

1. a single array, containing the base-26 values 0..25, used with the calc function, to arrive at consecutive decimal values for your alpha codes.

2. Three separate arrays, one for each digit in your codes, containing look-up values for each alpha character by digit.

The second version is more efficient, and I have included it here (mind the long lines):

----------->8-------------

H="ThreeDigitAlphaToBase26"

;value of characters in 1st to 3rd (right to left) digit of code

^!SetArray %digits3%=0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25

^!SetArray %digits2%=0;26;52;78;104;130;156;182;208;234;260;286;312;338;364;390;416;442;468;494;520;546;572;598;624;650

^!SetArray %digits1%=0;676;1352;2028;2704;3380;4056;4732;5408;6084;6760;7436;8112;8788;9464;10140;10816;11492;12168;12844;13520;14196;14872;15548;16224;16900

^!Set %offset%=64

;note: offsets a to 1, which has value zero in numbering system

;--------------------------------------------

;extract codes

^!SetListDelimiter ^%nl%

^!SetArray %codes%=^$GetDocMatchAll("^[a-z]{3}")$

;loop codes

^!Set %i%=0

:Loop

^!Inc %i%

;fetch code digits one at a time, consolidate in temp

^!Set %one%=^$CharToDec(^$StrUpper(^$StrIndex("^%codes^%i%%";1)$)$)$

^!Dec %one% ^%offset%

^!Set %temp%=^%digits1^%one%%

^!Set %two%=^$CharToDec(^$StrUpper(^$StrIndex("^%codes^%i%%";2)$)$)$

^!Dec %two% ^%offset%

^!Inc %temp% ^%digits2^%two%%

^!Set %tre%=^$CharToDec(^$StrUpper(^$StrIndex("^%codes^%i%%";3)$)$)$

^!Dec %tre% ^%offset%

^!Inc %temp% ^%digits3^%tre%%

;assign assembled code back to codes array

^!Set %codes^%i%%=^%temp%

;--------------------------------------------

:gap_trap

^!If ^%i%>1 SKIP_2

^!Set %OLD%=^%temp%

^!Dec %old%

;incrementing OLD should set it to same as new

^!Inc %OLD%

;temporarily disable for testing

^!If ^%old%<>^%temp% HANDLE_GAP

;if differene > 1 signal a gap

;--------------------------------------------

:NOGAP

^!Set %old%=^%temp%

^!Info ^%codes^%i%%

^!If ^%i%<^%codes0% LOOP

^!Goto END

:HANDLE_GAP

^!Info [L]There is a gap at ^%old% to ^%temp%^%nl%Continuing...

^!Set %OLD%=^%TEMP%

^!Goto NOGAP

----------->8-------------

Cheers,

Eb

PS

I'm guessing at some of the stuff below:

The conversion to hex failed because NoteTab saw the insertion of a plain caret as the begin of a parsable something, and when changed to ^%caret% in included the caret like an escaped character, no longer capable of triggering the parser.

As to the HextToInt function, it works fine, when an actual hex number is passed to it. - --- In ntb-clips@yahoogroups.com, "flo.gehrke" <flo.gehrke@...> wrote:
>

My pleasure. Joy

> --- In ntb-clips@yahoogroups.com, "joy8388608" <mycroftj@> wrote:

> >

> > Flo -

> >

> > Very interesting. Your clip is much faster than mine even

> > when I turned ScreenUpdate off. Mine took 41 seconds and

> > yours took 15 for 17550 lines (aaa to zzz with 26 .rr lines

> > removed). Why? I'm not sure...

>

> > Flo -

> >

> > Very interesting. Your clip is much faster than mine even when

> > I turned ScreenUpdate off. Mine took 41 seconds and yours took

> > 15 for 17550 lines (aaa to zzz with 26 .rr lines removed). Why?

> > I'm not sure...

>

> Joy,

>

> I think there are three main reasons for that:

>

> 1. Assigning the whole list to an array

>

> 2. Calculating ^$ConvertTo26$ only twice -- it's done three times in your clip

>

> 3. Gathering up the gaps with ^!Append and outputting them all at once -- no ^!InsertText

>

> > I wrote a quick clip to generate the lines aaa to zzz. Let

> > me know if anyone wants me to post the code.

>

> I put my hand up and would enjoy seeing that clip!

>

> Flo

>

Generate Base 26 numbers

; by Joy

^!Continue This will generate 17576 lines from aaa to zzz.

^!SKIP Leave Screen update on? (Slower...)

^!Setscreenupdate OFF

^!StatusShow Generating sequences aaa to zzz...

; Start with aaa

^!Set %I%=-1

:LoopStart

^!Inc %I%

^!Set %Num%=^%I%

; Find value of first digit (of 3) (will be 0 to 25)

^!Set %x%=^$Calc(INT(^%Num%/676))$

; Convert first digit to letter (will be a to z)

^!Set %B26%=^$DecToChar(^$Calc(^%x%+97)$)$

; adjust value of current number

^!Set %Num%=^$Calc(^%Num% - (^%x%*676))$

; Find value of second digit (of 3) (will be 0 to 25)

^!Set %x%=^$Calc(INT(^%Num%/26))$

; Convert second digit to letter (will be a to z) and append

^!Set %B26%=^%B26%^$DecToChar(^$Calc(^%x%+97)$)$

; adjust value of current number

^!Set %Num%=^$Calc(^%Num% - (^%x%*26))$

; Convert remaining value (0 to 25) to letter (will be a to z) and append

^!Set %B26%=^%B26%^$DecToChar(^$Calc(^%Num%+97)$)$

; Output value

^!InsertText ^%B26%^%NL%

^!If "^%B26%" <> "zzz" LoopStart

^!Sound SystemExclamation