[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: XyWrite for Windows



Robert wrote:
>What, Harry, is the advantage of using your program if it generates code
>which you wouldn't dream of using? Code which is prolix and slow and
>archaic in its structure?
  The code is not prolix and slow--this isn't a compiler, actually, just a
translator. So the code produced is the very same as I'd write in XPL. Now
that isn't 100% true, because I even implemented (but almost never use) a
LEFT$, RIGHT$, and MID$ functions that compile to produce clunky code. I
don't even think those work properly with Xy4. But aside from a few arcane
things like that, it is just a "front-end" for inputting the code easily,
for being able to comment it easily (anything after a semicolon is treated
as a comment), for being able to format it at will (any line endings, blank
lines, tabs, and spaces you want anywhere), and, most significantly, to be
able to have named variables for more complex routines. My illustrative
example didn't have any named variables because it was so simple. But code
with variable names (like "address$" and "line.length") is almost
self-documenting. Same for named subroutines. My pgm also produces, at the
end of the final XPL "object" code, a list of what the numeric s/g's were in
terms of the names. I'll include a sample at the end of this.

> If you have to edit it after you're done, using
>the native language of XyWrite, then what's the point?
You don't HAVE to. Often, it's convenient for debugging: when the thing
doesn't work, I put in an  in the object code at various places to
isolate the problem section. That's all.

> If you're going to
>familiarize yourself *anyway* with the molecular particles of XyWrite's
>inner structure, like functions, what's the point? The *only* conceivable
>advantage is Named rather than Numbered variables (S/Gs), which -- if you
>really want them -- are incredibly easy to implement without XyBasic, and
>always have been.
 I began with an XPL program to do that within XY. Then I thought, "why do
I have to type all those PFUNC's?" I'll translate those too. Eventually, I
found it convenient to put more and more into the "front end"--and I changed
from having the translator be an XPL program to a compiled Basic program (an
.exe file).
 I did all this because it WAS helpful, so it is a little strange to have
to defend against a priori arguments that it COULDN'T be helpful.
 Now, I concede that my situation may be somewhat idiosyncratic: I spent
years programming in CBASIC, so it is like my native tongue. For those who
aren't that at home in BASIC, maybe the rewards are fewer. Also, I never
figured out help frames.

>
>Incidentally, the "translation" that XyBasic generates:
>
>>255>BC va \XC LB .
>LE +1>
>
>is wordy.
I had an answer to this, but I had to remove it after reading your "modern"
code below.

> There are other problems also -- it doesn't generate "255
>possible VA functions" (what are VA functions?); rather, it generates Error
>Messages 1-255. Now why would I want to see 1-255 when there are 1300+
>error messages? all a muddle -- but lets put that aside,
 Okay, okay, I slipped. It's the error messages that I display with this
program. Why did I want it? Because I had a problem in Xy4 that I posted
here (and got no answer to) about certain error messages causing
problems--all and only the ones that ended in a "&", and I learned that the
"&" was the problem by looking at 255 of them. I picked 255 because it is FF
in hex, and I felt there was a hex on me (a pathetic attempt at humor, but
I'm running scared here because I've been called a humorless prig).

> along with the
>ridiculous proposition that its better to translate than use machine
>language, and let's just examine your "translated" result. This is faster,
>cleaner, completely silent, no forward references, no loops, all operations
>performed in memory (scandalous to do it on CMline!) -- in a word, modern:
>
>GT +1>.{Tab}
>+">>">
 Huh??? What is "CUA"? It seems to refer to  at the end, but CU is not
documented. No fair! What is the meaning of --what do the quotes
do? Your program runs, so you are obviously at a higher level of Being than
I have attained. But we knew that before.
  And since your code above uses quote marks in a way that XyBasic does not
allow for, because I had no idea of such a construction as , I
can't see how to generate that XPL trick via XyBasic.

>In short, if we must have Basic, then at least let's have one that is
>written with a thorough grounding in XPL, and which we're entitled to shout
>and scream about if it isn't economical or, worse, makes mistakes.

 When TWPFKAXY comes out with its BASIC, I'll probably abandon XyBasic. But
not until then.

What follows is a sample program in XyBasic and then the XPL code it
translates to. Its function is, when paired with another program, to allow
for collapsible outlines. I forget whether this version even works--I did it
for a friend and it is probably specific to his needs. But it should give an
idea of the clarity added by writing in BASIC.

I've noted the things changed for emailing:
; =================================================================
;  I changed the guillemets to angle brackets for emailing
'dx
print "ÿ?/"  ; don't show markers --a "NM" function in the actual pgm
error.bell$ = va eb
com "d eb=0"
original.cursor = curpos
'xd 'tf
'wg
deepest.indent = 0
1tab$ = "	"; there's a tab character in there in the actual pgm
work.tabs$ = ""
FIND.DEEPEST.SHOWING.LEVEL:
 work.tabs$ = work.tabs$ + 1tab$  ; starts with 1 tab
 'lb com "se /" work.tabs$ "/"
 if error then goto out.tab.loop  ; if not found, deepest = previous
 incr deepest.indent   ; increments the variable by 1
 goto find.deepest.showing.level
out.tab.loop:
if deepest.indent = 0 then _
    'bc print " Can't collapse any further" : stop
if deepest.indent > 20 then _
    'bc print "found an over 20-tab indent--too many!" : stop
parse work.tabs$, 1tab$, front$, match$, end$ ; cut out extra tab from loop
work.tabs$ = end$
x = len(work.tabs$) ; in the end, I didn't need this variable
'tf
'xp
com "ci /ÿ0A>/>ÿ0A/" ; wildcards in actual pgm
'wg
loop.top:  ; again, the stuff below is wildcards in the pgm
 com "ci /ÿ0A" work.tabs$ "ÿÀ×ÿ0A/ÿ0Aÿ0A/"
 if error then goto all.done
goto loop.top
ALL.DONE:
'xp
com "ci />ÿ0A/ÿ0A>/" ; more wildcards
com "d eb=" error.bell$
'wg
'do
levels.showing = deepest.indent - 1
'bc print " exposed are levels 0 to " levels.showing
'bx "jmp " original.cursor
'q2
;===================================================
Now here's the XPL code generated (Robert: spare yourself: don't look):

DX NM >BC d
eb=0XC >XD TF WG +>
LB BC se
//XC >+1>==0>BC Can't
collapse any further>20>BC found an over 20-tab indent--too
many!>)>TF XP BC ci
/
>/>
/XC WG BC ci
/
W
/
W>
/XC >XP BC ci
/>
/
>/XC BC d eb=XC WG DO -1>BC exposed are levels 0 to

BX jmp Q2 
  Variables & Subs            Labels
 01 = ERROR.BELL$           lbA =  FIND.DEEPEST.SHOWING.LEVEL
 02 = ORIGINAL.CURSOR         lbB =  OUT.TAB.LOOP       
 03 = DEEPEST.INDENT          lbC =  LOOP.TOP         
 04 = 1TAB$              lbD =  ALL.DONE         
 05 = WORK.TABS$                             
 06 = FRONT$                               
 07 = MATCH$                               
 08 = END$                                
 09 = X                                 
 10 = LEVELS.SHOWING                           

Harry Binswanger
hb@xxxxxxxx