Quantcast

De-vectoring a vector

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

De-vectoring a vector

howie
This post has NOT been accepted by the mailing list yet.
My piece of code that is giving concern is:

dimension=234;
echo(len(str(dimension)));
for(posn=[0:len(str(dimension))-1]) {
        idx=search(str(dimension)[posn],chars);
        echo (idx);
        for(col=[0:4]) {
                for(row=[0:6]) {
                        if(charbits[idx][col][row]) {
                                echo(charbits[idx][col][row]);
                                translate([col+(posn*6),row])
                                square([1,1],center=false);
                        }
                }
        }
}

chars is the 95 character list (excuse the wrap):
 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

The search function looks in a list of the 95 printable ASCII characters from SPACE to ~ inclusive and returns the position of the characters "2", "3", "4" respectively as 18, 19, 20 (starting from the SPACE at position 0).

charbits is a nested vector of these same 96 characters defined as 7 row x 5 col bit maps.

When I run this routine the output is:
ECHO: 3
ECHO: [18]
ECHO: [19]
ECHO: [20]

I know the charbits vector works because if I substitute [18], [19], [20] for [idx] then I get the generated bitmaps.

My question is:  How do I de-vector the output from the search line so that I have numbers instead of vectors.

TIA.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: De-vectoring a vector

howie
Problem solved.

Extract the 0th element from the vector.

echo (idx) produced ECHO: [18}
echo (idx[0]) produces ECHO: 18
Loading...