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

Re: [StrongED] Re: StrongHelp crashes on launch



In message <0a80953455.martin@xxxxxxxxxxxxxxxx>
          Martin Bazley <martin.bazley@xxxxxxxxxxxxxxxx> wrote:

> The following bytes were arranged on 17 Dec 2015 by Martin :
>
> > In article <98ff6c3355.fjgraute@xxxxxxxxx>,
> >    Fred Graute <fjgraute@xxxxxxxxx> wrote:
> > > In message <ccf85d3355.martin@xxxxxxxxxxxxxxxx>
> > >           Martin Bazley <martin.bazley@xxxxxxxxxxxxxxxx> wrote:
> >
> > [Snip]
> >
> > > The problem, as I remember, was how to handle all the old 26-bit !Pre's
> > > that are out there. Possibly scan the code before execution and raise a
> > > warning when we're on a 32-bit machine and !Pre isn't 32-bit?
> >
> > That would be neat ... if it is practical to do.
> > If warned I would have fixed the Reporter !Pre a decade ago!
>
> If I may make a suggestion here, the use of machine code to perform
> simple string manipulation seems unnecessary in this day and age
> (arguably in any day and age).  Would it be practical to deprecate the
> !Pre file entirely and replace it with something else, say "!Pre2",
> which takes its arguments in a more portable way?

It would be possible but would it be practical? You'd still have the old
26-bit !Pre's out there, Pre2 just adds another element into the mix. If
you simply ignore !Pre then older manuals no longer work as intended.

> There wouldn't be that much extra overhead, considering it's only called
> once per manual.  I suppose the main problem would be working out some
> way to pass the arguments back, particularly one that wouldn't break in
> a multi-core scenario.

The best way, IMO, would be to use a system variable. Language agnostic
and easy to read and write. I'm going to ignore the multi-core scenario
for now, we can cross that bridge when it actually exists.

> The standard SWI !Pre could be much more maintainably expressed in a
> form such as the following:
>
> IF LEFT$(input$,1)="X" input$=MID$(input$,2)
> SYS "XOS_ReadUnsigned",,input$ TO ,,value%;flags%
> IF (flags% AND 1)=0 SYS "OS_SWINumberToString",value% AND NOT &20000,STRING$(255,CHR$13),255 TO ,input$

It needs a bit more than that, something like:

  DIM blk% 256
  base%   = 10
  start%  = 0
  input$  = ""
  output$ = ""
  sysvar$ = "StrongHelp$LookupWord"

  SYS "XOS_ReadVarVal",sysvar$,blk%,255,0,0 TO ,,read% ;flags%
  IF (flags% AND 1) = 0 THEN blk%?read% = 13 : input$ = $blk%

  IF input$ <> "" THEN
    IF LEFT$(input$,1)="X" THEN
      output$ = MID$(input$,2)
    ELSE
      IF LEFT$(input$,4) = "!x26" THEN base% = 16 : start% = 5
      SYS "XOS_ReadUnsigned",base%,MID$(input$,start%) TO ,,value% ;flags%
      IF (flags% AND 1) = 0 THEN
        value% = value% AND NOT &20000
        SYS "XOS_SWINumberToString",value%,blk%,255 TO ,output$ ;flags%
        IF (flags% AND 1) = 1 THEN output$ = ""
      ENDIF
    ENDIF
  ENDIF

  IF output$ <> "" THEN SYS "XOS_SetVarVal",sysvar$,output$,0,0

  END

To test it you can use this TaskObey file:

  Set StrongHelp$LookupWord "XOS_Byte"
  Echo Before: <StrongHelp$LookupWord>
  Run <Obey$Dir>.!Pre2
  Echo After:  <StrongHelp$LookupWord>

> ...And of course I got the undefined instruction error every time I
> tried to look up the documentation for the SWIs in that code snippet.

Oddly enough I have so far only seen it once despite a lot of testing.
In most cases it works or there's an error message from StrongHelp: "no
help on that word".

Cheers,
Fred.

-- 
StrongED Developer
http://www.stronged.iconbar.com/

--
To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxxxxx
List archives at http://www.Torrens.org.uk/RO/StrongED/index.html