Re: Matheval ... the next step (for me)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Mike777 wrote:
> 
> Matt Lewis wrote:
> > 
> > Mike777 wrote:
> > > 
> > > What I'd like to do is this:
> > > 
> > > block(
> > > x := 1,
> > > y := 2,
> > > (mySequence := "I know this works " & {STR,{ADD,x,y},{}} & " times")
> > > )
> > > 
> > > Is what I want to do possible?
> > 
> > That should work, but due to a bug in the parsing routine for STR, it
> > doesn't.  In texteval.e, change CStr to this:
> > }}}
<eucode>
> > function CStr( sequence expr, integer tok )
> >     if tok = length( expr ) or (not CheckCollapsed({expr[tok+1]}))  then
> >         return {{INVALID, "Missing argument for STR()", {}}}
> >     end if
> > 
> >     expr[tok][ARG1] = expr[tok+1]
> >     return expr[1..tok] & expr[tok+2..length(expr)] 
> > end function
> > </eucode>
{{{

> 
> Wow!  Are you sure this isn't IRC?
> 
> Well, the good news is that it now runs.  The bad news is that any line with
> the STR function on it disappears.  I have tested the equivalent of:
> 
> BLOCK(
> (mySeq := "Test"),
> x := 1,
> y := 2,
> (mySeq := mySeq & {STR,{ADD,x,y},{}} ),
> (mySeq := mySeq & mySeq)
> )
> 
> I get "TestTest".  Nothing between the two tests.
> 
> Any suggestions at this point?
> 
> Thanks again.

Further testing shows that the return from the CStr function is always the error
condition, which causes Matheval to discared the statement it is embedded in.  I
have tried many, many versions of the STR function (with quotes, without quotes,
with double quotes, without double quotes, with 1 argument filled in and the
second one empty, etc.).  All return the error condition (which I confirm with a
pretty print of all the matheval results, as per the documentation).

Mike

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu