Mojca Miklavec | 12 Sep 10:43 2011
Picon

strings with > 4000 characters

Dear list,

I would like to ask if there is any trick that enables splitting
strings with > 4000 characters.

I would like to use
    substring (10000,10006) of some string

When drawing functions, one can scale down calculations towards lower
numbers and with some special care, one can still make it work. Is
there any similar trick (excluding metapost 2) for strings?

Thank you,
   Mojca
--
http://tug.org/metapost/

Nicola | 12 Sep 15:42 2011
Picon

Re: strings with > 4000 characters

In article 
<CALBOmsad+S2kEptEDE=ct6ptBRZ24nscMxeS5VixQExUi+JM4Q <at> mail.gmail.com>,
 Mojca Miklavec <mojca.miklavec.lists <at> gmail.com> wrote:

> Dear list,
> 
> I would like to ask if there is any trick that enables splitting
> strings with > 4000 characters.
> 
> I would like to use
>     substring (10000,10006) of some string
> 
> When drawing functions, one can scale down calculations towards lower
> numbers and with some special care, one can still make it work. Is
> there any similar trick (excluding metapost 2) for strings?

Three tricks come to my mind (all untested!):

1) Repeatedly eat chunks from your strings, e.g.

for i = 1 upto 5 : s := substring(2000,infinity) of s; endfor
s := substring(0,6) of s;

2) Set warningcheck:=0;

3) Use dviluatex as the TeX engine. For example, if the substrings are to be 
drawn as labels, you may write

picture l; l = btex \directlua { LUA CODE HERE } etex;

(Continue reading)

Dan Luecking | 12 Sep 17:36 2011
Picon

Re: strings with > 4000 characters

At 03:43 AM 9/12/2011, Mojca Miklavec wrote:
>Dear list,
>
>I would like to ask if there is any trick that enables splitting
>strings with > 4000 characters.
>
>I would like to use
>     substring (10000,10006) of some string
>
>When drawing functions, one can scale down calculations towards lower
>numbers and with some special care, one can still make it work. Is
>there any similar trick (excluding metapost 2) for strings?

You might store long strings as arrays of shorter
strings. For example, if a long string is stored
as S0, S1, S2, ... S[N], and each one (except the
last) is 1000 characters long (say), then characters
between 10000 and 10006 of the whole could be
accessed as
    substring (0, 6) of S10.

With some extra effort, an array of strings of variable
length could be accessed similarly.

The problem is not so much the length of the string as
the size of the numbers required to index it. In the
above scenario, one would have to pass the index into
the array of strings and then the pair of locations in
that string.

(Continue reading)

Dan Luecking | 12 Sep 18:00 2011
Picon

Re: strings with > 4000 characters

At 08:42 AM 9/12/2011, you wrote:
>In article
><CALBOmsad+S2kEptEDE=ct6ptBRZ24nscMxeS5VixQExUi+JM4Q <at> mail.gmail.com>,
>  Mojca Miklavec <mojca.miklavec.lists <at> gmail.com> wrote:
>
> > Dear list,
> >
> > I would like to ask if there is any trick that enables splitting
> > strings with > 4000 characters.
> >
> > I would like to use
> >     substring (10000,10006) of some string
> >
> > When drawing functions, one can scale down calculations towards lower
> > numbers and with some special care, one can still make it work. Is
> > there any similar trick (excluding metapost 2) for strings?
>
>Three tricks come to my mind (all untested!):
>
>1) Repeatedly eat chunks from your strings, e.g.
>
>for i = 1 upto 5 : s := substring(2000,infinity) of s; endfor
>s := substring(0,6) of s;

Note that infinity is a plain.mp variable that still
equals 4095.99998 so the above code would only see
the first 4096 characters of s.

>2) Set warningcheck:=0;

(Continue reading)

Mojca Miklavec | 12 Sep 20:41 2011
Picon

Re: strings with > 4000 characters

On Mon, Sep 12, 2011 at 17:36, Dan Luecking wrote:
> At 03:43 AM 9/12/2011, Mojca Miklavec wrote:
>>
>> Dear list,
>>
>> I would like to ask if there is any trick that enables splitting
>> strings with > 4000 characters.
>>
>> I would like to use
>>    substring (10000,10006) of some string
>>
>> When drawing functions, one can scale down calculations towards lower
>> numbers and with some special care, one can still make it work. Is
>> there any similar trick (excluding metapost 2) for strings?
>
> You might store long strings as arrays of shorter
> strings. For example, if a long string is stored
> as S0, S1, S2, ... S[N], and each one (except the
> last) is 1000 characters long (say), then characters
> between 10000 and 10006 of the whole could be
> accessed as
>   substring (0, 6) of S10.

If I don't come up with something better, I will probably end up using
this indeed.

> The problem is not so much the length of the string as
> the size of the numbers required to index it.

I got that :(
(Continue reading)

Nicola | 13 Sep 08:56 2011
Picon

Re: strings with > 4000 characters

In article <0LRF00I7Y31MRIEG <at> mailhost.uark.edu>,
 Dan Luecking <luecking <at> uark.edu> wrote:

> >for i = 1 upto 5 : s := substring(2000,infinity) of s; endfor
> >s := substring(0,6) of s;
> 
> Note that infinity is a plain.mp variable that still
> equals 4095.99998 so the above code would only see
> the first 4096 characters of s.

Yep, silly advice. Sorry.
The other points you've made are very interesting, too.

 <at> Mojca: warningcheck:=0 would allow you to use indexes less than 16383.9999 
(please someone correct me if I'm wrong).

Nicola

--
http://tug.org/metapost/

Nicola | 13 Sep 12:53 2011
Picon

Error on using implicit suffix parameter (mpost 1.504)

Hi,
feeding mpost 1.504 (from TeX Live 2011) with the following code

vardef XYZ.test =
   for i = incr(# <at> ) downto 0 : message decimal(i); endfor
enddef;
XYZ = 5;
XYZ.test;

results in

! A statement can't begin with `:='.
<to be read again> 
                   :=
downto->begingroup(SUFFIX2):=
                             (SUFFIX2)+1;(SUFFIX2)endgroup
<to be read again> 
                   step
downto->step
            -1until
implicit_suffix_param->....i=incr((SUFFIX0))downto
                                                  0:message.decimal(i);endfo...
l.12 XYZ.test
             ;
? 

I'm pretty sure that this used to work previously. Can anyone confirm and/or 
reproduce this? The bug only occurs under the following conditions:

- incr (or decr) is used in a for loop with upto or downto;
(Continue reading)

Taco Hoekwater | 13 Sep 13:26 2011

Re: Error on using implicit suffix parameter (mpost 1.504)

On 09/13/2011 12:53 PM, Nicola wrote:
>
> I'm pretty sure that this used to work previously. Can anyone confirm and/or
> reproduce this? The bug only occurs under the following conditions:
>
> - incr (or decr) is used in a for loop with upto or downto;
> - incr/decr's argument is enclosed in parentheses.
>
> Both incr # <at>  and (incr(# <at> )) are ok.

Same problem here (and in 1.211 the code works fine). I've added a bug
here: http://tracker.luatex.org/view.php?id=715

Best wishes,
Taco
--
http://tug.org/metapost/

Nicola | 13 Sep 14:14 2011
Picon

Re: Error on using implicit suffix parameter (mpost 1.504)

In article <4E6F3DDD.3000901 <at> elvenkind.com>,
 Taco Hoekwater <taco <at> elvenkind.com> wrote:

> On 09/13/2011 12:53 PM, Nicola wrote:
> >
> > I'm pretty sure that this used to work previously. Can anyone confirm and/or
> > reproduce this? The bug only occurs under the following conditions:
> >
> > - incr (or decr) is used in a for loop with upto or downto;
> > - incr/decr's argument is enclosed in parentheses.
> >
> > Both incr # <at>  and (incr(# <at> )) are ok.
> 
> Same problem here (and in 1.211 the code works fine). I've added a bug
> here: http://tracker.luatex.org/view.php?id=715

Ok, I've posted a follow-up there.
Nicola

--
http://tug.org/metapost/


Gmane