[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Hard number program, as written in XyBasic
- Subject: Hard number program, as written in XyBasic
- From: Harry Binswanger hb@xxxxxxxx
- Date: Fri, 24 Apr 2009 08:55:05 -0400
Just FYI, here's the "source" code for my recently posted HDNUM.PGM:
defstr u2$ = 50 <=== set the variable named "u2$" to be s/g 50
comx "es 1" <==== "comx" translates to [BX] ...[Q2] with quoted stuff in
between
<==== blank lines, tabs, extra spaces, all allowed
c0 = 1
c1 = 1
c2 = 1
c3 = 1
c4 = 1
c5 = 1
c6 = 1
c7 = 1
c8 = 1
c9 = 1
dc$ = "DC" ; for parse use <======= semicolon introduces a comment
equal$ = "=" ; for parse use
null$ = ""
'tf 'xp <======== prepended apostrophes translate as PFUNCs
loop:
head$ = null$ : tail$ = null$ : dummy$ = null$ : new.tail$ = null$
comx "se/f /" lft.g$ "C[N]" rt.g$ " +[O]" lft.g$ "DC[W]"
rt.g$ "/"
if error then stop <==== lft.g$ and rt.g$ are built-in constants for
the guillemets
'cr 'df comx "se/f /" rt.g$ "/" ; don't include the rt.g
'df
this.c$ = savedef$ ; this.c$ = e.g., C1 or DC3=16
if this.c$ = null$ then 'bc print "this.c$ is null--can't parse it" : stop
; now deal with any counter-resets, e.g., DC3=16
parse this.c$, dc$, head$, dummy$, tail$
if dummy$ = null$ then goto skip ; not a counter-reset, so skip the below
;'bc print "HERE - in re-set section" : stopx <======= used in debugging
; COUNTER RE-SET SECTION
'rd 'bd 'rc
; now tail$ is, e.g., 3=16
parse tail$, equal$, head$, dummy$, new.tail$
if head$ = 0 then c0 = int(new.tail$)
if head$ = 1 then c1 = int(new.tail$)
if head$ = 2 then c2 = int(new.tail$)
if head$ = 3 then c3 = int(new.tail$)
if head$ = 4 then c4 = int(new.tail$)
if head$ = 5 then c5 = int(new.tail$)
if head$ = 6 then c6 = int(new.tail$)
if head$ = 7 then c7 = int(new.tail$)
if head$ = 8 then c8 = int(new.tail$)
if head$ = 9 then c9 = int(new.tail$)
'cl 'cl
goto loop
skip: ; REGULAR COUNTER SECTION
'rd 'bd 'rc
; this.c$ is, e.g.,