[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [StrongED] DigDirSED 1.01 available

In message <9e79eb2e53.fjgraute@xxxxxxxxx> you wrote:

> Which version of Lua are you using.
> Everything is fine when running Lua 5.41 but with Lua 5.50 things fail
> as you've described. It seems that Lua 5.50 doesn't zero terminate
> string in some sisuations. Perhaps Gavin can shed some light on this.

Yes. I cannot remember exactly when, but at some point I decided that
invisibly inserting terminating control characters was a bad policy.
Far better to let the user decide when, and which, control characters
might be needed. So the rule is "$[adr] = s" stores the string s at
adr. If it needs to be null terminated do "$[adr] = s..'\0'". Remember
that, unlike Basic, strings in Lua can have characters with any ASCII
code you like. There are no terminating control characters needed in Lua.
The same policy applies to string arguments in sys calls.
Such string arguments are really stored in a buffer (with no terminating 
control characters automatically appended) and the buffer's address is 
what actually gets fed to the register before the SWI is called. So much for
poking (moving strings from Lua to RISC OS). For peeking (moving strings
from RISC OS to Lua) the possibilities are:

s = $[adr]  -- string at adr upto but not including first ASCII nul,
s = $(adr)  -- string at adr upto but not including first control character,
s = $(adr,n) -- string at adr of n characters, whatever they are,

These details are in the html manual that comes in the distribution.

So it may well be that MatchText needs updating.

It is bad policy to use "dim" inside loops anyway, as that causes
"space leaks". 

Easiest way of updating MatchText:
Replace the two lines (6 & 7)

     local sys,dim,dir in riscos

  local sys,dir in riscos
  local dim = \ (s) => s .. '\0' end -- is nothing sacred?

and remove the last line

end -- do

It is not necessary to enclose the whole program in a do ... end block.
At one point I used to do this because I had not understood that the
whole program constitutes a block in itself, and that it is perfectly
OK for a variable to be local to the whole program (this does not make
it a global variable - that is what I had not understood). There is no
semantic difference between a global variable and one that is local 
to the whole program, but there is an operational difference.

I apologize for the changes. RiscLua has always been changing, though
there have been long periods of stagn... , sorry, stability.
The next change coming up is to the library for writing wimp tasks
and using the toolbox. For ease of packaging the organization of the
distribution has changed too, so it will be possible just to download
the relevant part of the distribution:

base  -  basic distribution with binaries
doc   -  documentation, StrongHelp and html manual
libs  -  libraries
ex    -  examples
utils -  utilities, make standalone programs, compile to bytecode

Lots of the changes, to the documentation, for example, take place
with no fanfare. After all, it always needs improvement. So be
prepared to download on a regular basis, especially when the weather
is likely to be stimulating the phagocytes. 

Gavin Wraith (gavin@xxxxxxxxxxxxxxx)
Home page: http://www.wra1th.plus.com/

To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxxxxx