Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

basic code formatter

35 views
Skip to first unread message

Mike Preece

unread,
Dec 16, 2009, 4:28:39 AM12/16/09
to
Hello

Can someone post Basic source code to format basic source code so that
I can copy and paste it please.

I am on a mvBase site without admin rights to my workstation and so am
unable to install UltraEdit or any of the other non-Pick programs
capable of formatting PickBasic code. The mvBase version of BLIST
seems to be able to print but not update. I thought I had a Basic code
formatter somewhere but can't find it right now so would be grateful
if someone could post the code here.

Brian Speirs

unread,
Dec 16, 2009, 8:23:44 AM12/16/09
to
Hi Mike,

There is code for a BASIC formatter on PickWiki.

Cheers,

Brian

Mike Preece

unread,
Dec 16, 2009, 9:14:35 AM12/16/09
to
> > if someone could post the code here.- Hide quoted text -
>
> - Show quoted text -

Thanks Brian. I had a look. That code seems to be U2 specific and in
need of mods before it could be used on mvBase. Meanwhile I found some
code here originally written by Ricky Ginsburg by googling for
"mvbasic formatting". I modified that code slightly, including having
it default to the "SOURCE" file and made various other little tweaks.
The following code doesn't do the full job. It doesn't, for example,
cope well with non-numeric labels and empty lines, 2 END CASE
statements in succession, etc.. There's more that could be done but
here is what I have atm...

STMT=TRIM(SENTENCE())
IF INDEX(STMT,' ',2) THEN
FILE=FIELD(STMT,' ',2)
KEY=FIELD(STMT,' ',3)
END ELSE
FILE='SOURCE'
KEY=FIELD(STMT,' ',2)
END
EQU BELL TO CHAR(7),FM TO CHAR(254)
PROMPT ''
OPEN FILE TO F.FILE ELSE
PRINT;PRINT;PRINT "Cannot open '":FILE:"' file. Hit
<ENTER>":;INPUT A,2
STOP
END
READU ORIG.SOURCE FROM F.FILE,KEY ELSE STOP
READVU CHK FROM F.FILE,"OLD.":KEY,1 THEN
LOOP
CRT "OLD. VERSION EXISTS. OVERWRITE? (Y/N) ":
INPUT ANS,1
UNTIL ANS='Y' OR ANS='N' DO REPEAT
IF ANS='N' THEN STOP
END
WRITE ORIG.SOURCE ON F.FILE,"OLD.":KEY
SP=6;INDENT=3;SPX=6;CFLG=0;BFR=0;LINE.NO=0
MAXLN=DCOUNT(ORIG.SOURCE,@AM)
FOR LINE.NO=1 TO MAXLN
LOOP
LN=ORIG.SOURCE<LINE.NO>
LN=TRIMF(LN)
LN=TRIMB(LN)
WHILE LN='' DO
LINE.NO+=1
REPEAT
LABEL='';L=1;X=LN 'R#5'
IF NUM(LN[1,1]) THEN
LOOP
L=L+1
WHILE NUM(LN[L,1]) DO
REPEAT
LABEL=LN[1,L-1]
LN=LN[L,32767]
LN=TRIMF(LN)
LN=TRIMB(LN)
END
CMND=FIELD(LN,' ',1)
BEGIN CASE
CASE LN[1,1]='*' OR LN[1,1]='!' OR LN[1,3]='REM'
SPX=0
CASE (CMND='FOR' AND INDEX(LN,'NEXT',1)=0) OR CMND='BEGIN'
OR CMND='LOOP'
IF CMND='LOOP' AND X='EPEAT' THEN NULL ELSE SP=SP+3
IF CMND='BEGIN' THEN BFR=0
CASE CMND='CASE'
IF BFR THEN
IF CFLG THEN
SPX=SPX-INDENT;SP=SPX;CFLG=0
END
END ELSE
BFR=1;CFLG=0
END
IF INDEX(LN,';',1) AND NOT(INDEX(LN,'*',1)) AND NOT
(INDEX(LN,'REM',1)) AND NOT(INDEX(LN,'!',1)) THEN NULL ELSE SP=SP+3
CASE CMND='END' OR CMND='NEXT' OR CMND='WHILE' OR
CMND='UNTIL' OR CMND='REPEAT'
SPX=SPX-INDENT
IF (CMND='END' AND X#' ELSE') OR X='EPEAT' OR
CMND='NEXT' THEN SP=SPX
IF X=' CASE' THEN
IF CFLG THEN
CFLG=0;SPX=SPX-INDENT
END
SP=SPX
END
CASE X=' THEN' OR X=')THEN' OR X='>THEN' OR X=' ELSE' OR
X=')ELSE' OR X='>ELSE'
SP=SP+INDENT
CASE 1;IF BFR THEN CFLG=1 ELSE CLFG=0
END CASE
NEW.LINE=LABEL:STR(' ',SPX-LEN(LABEL)):LN
CRT NEW.LINE
NEW.SOURCE<LINE.NO>=NEW.LINE
SPX=SP
NEXT LINE.NO
WRITE NEW.SOURCE ON F.FILE,KEY
STOP


Ed Sheehan

unread,
Dec 16, 2009, 11:39:55 AM12/16/09
to
I've used this one for years. See if it works for you.

Ed
---
001 PROMPT CHAR(0)
002 EQU AM TO CHAR(254)
003 MAX.LEN = 99700
004 FILE.FLAG = 0
005 SEL.FLAG = 0
006 SHOW.STRUCTURE = 0
007 EQU NO TO 'N', YES TO 'Y'
008 PRINTER OFF
009 PRINTER.ON = 0
010 10 PRINT 'DATA/BASIC FILE NAME - ':
011 INPUT FILENAME
012 OPEN '',FILENAME TO FILE ELSE
013 PRINT 'CANNOT OPEN FILE - ': FILENAME
014 GOTO 10
015 END
016 20 PRINT 'DATA/BASIC PROGRAM NAME - ':
017 INPUT NAME
018 BEGIN CASE
019 CASE NAME = '*'
020 SELECT FILE
021 SEL.FLAG = 1
022 CASE NAME = ''
023 SEL.FLAG = 1
024 CASE 1
025 READ ITEM FROM FILE, NAME ELSE
026 PRINT 'CANNOT FIND ITEM ':NAME:' IN FILE ':FILENAME
027 GOTO 20
028 END
029 SEL.FLAG = 0
030 END CASE
031 START.SP = -6
032 START.ID = 3
033 * DISP = 1
034 OPT = 'NONE'
035 TRANSLATE.TO.UPPER.CASE = 0
036 END.OF.LIST = 0
037 !
038 PRINT 'ENTER OPTION LIST ':
039 INPUT OPT
040 30 OPT = TRIM(OPT)
041 MAX = COUNT(OPT,',') + (OPT # '')
042 FOR I = 1 TO MAX
043 OPTION = FIELD(OPT,',',I)
044 BEGIN CASE
045 CASE OPTION = 'Y'
046 DISP = 1
047 CASE OPTION = 'N'
048 DISP = 0
049 CASE OPTION = 'P'
050 PRINTER.ON = 1
051 CASE NUM(OPTION) AND START.SP = -6
052 START.SP = OPTION
053 CASE NUM(OPTION)
054 START.ID = OPTION
055 CASE OPTION = 'F'
056 FILE.FLAG = 1
057 CASE OPTION = 'U'
058 TRANSLATE.TO.UPPER.CASE = 1
059 CASE OPTION = 'S'
060 SHOW.STRUCTURE = 1
061 CASE 1
062 PRINT 'Illegal option "':OPTION:'"'
063 STOP
064 END CASE
065 NEXT I
066 IF SEL.FLAG THEN FILE.FLAG = 1
067 IF NOT(PRINTER.ON) THEN SHOW.STRUCTURE = 0
068 IF PRINTER.ON THEN
069 LINE.JUST = 'R%4 '
070 FILE.FLAG = 0
071 START.SP = 6
072 START.ID = 3
073 END ELSE LINE.JUST = 'R%3 '
074 !
075 LOOP
076 IF SEL.FLAG THEN
077 READNEXT NAME ELSE SEL.FLAG = 0
078 END
079 IF NOT(SEL.FLAG) THEN
080 IF NAME = '' THEN END.OF.LIST = 1
081 END
082 UNTIL END.OF.LIST DO
083 FOUND = 1
084 READ ITEM FROM FILE, NAME ELSE
085 PRINT 'CANNOT FIND ITEM ':NAME:' IN FILE ':FILENAME
086 FOUND = 0
087 END
088 IF FOUND THEN
089 SP = ABS(START.SP)
090 ID = ABS(START.ID)
091 PRINT
092 SPX = SP
093 LSP = SP
094 SSP = SP
095 LINE.NO = 0
096 NEWITEM = ''
097 PRINT
098 PRINT 'PROCESSING ':NAME
099 IF PRINTER.ON THEN
100 PRINTER ON
101 HEADING FILENAME 'L#15 ':NAME 'L#30 ':TIMEDATE() :' Page
':"'PLL'"
102 END
103 NUM.LINES = DCOUNT(ITEM,AM)
104 LOOP
105 LINE.NO = LINE.NO + 1
106 LINE = ITEM<LINE.NO>
107 IF TRIM(LINE) = '' THEN LINE = '!'
108 UNTIL LINE.NO > NUM.LINES DO
109 IF LINE.NO + 5 = NUM.LINES THEN DISP = 1; CRT ''
110 IF TRANSLATE.TO.UPPER.CASE THEN LINE = OCONV(LINE,'MCU')
;!ULT
111 LABEL = ''
112 IF NUM(TRIM(LINE)[1,1]) OR ((TRIM(LINE)'R#') = ':' AND
NOT(INDEX(LINE,'CRT:',1)) AND NOT(INDEX(LINE,'PRINT:',1)) AN
D NOT(INDEX(TRIM(LINE),' ',1))) OR (FIELD(LINE,' ',1)'R#' = ':' AND
FIELD(LINE,':',1)#'CRT') THEN
113 LOOP WHILE LINE[1,1] = ' ' DO LINE = LINE[2,MAX.LEN]
REPEAT
114 IF NUM(LINE[1,1]) THEN
115 LABEL.TYPE = 'N'
116 FOR L = 2 TO MAX.LEN UNTIL NOT(NUM(LINE[L,1])) ; NEXT
L
117 END ELSE
118 LABEL.TYPE = 'A'
119 L = INDEX(LINE,':',1) + 1
120 END
121 LABEL = LINE[1,L-1]
122 LABEL = LABEL:SPACE(LSP-LEN(LABEL))
123 IF LABEL[LEN(LABEL),1] # ' ' THEN LABEL = LABEL:' '
124 LINE = LINE[L,MAX.LEN]
125 END
126 LOOP WHILE LINE[1,1] = ' ' DO LINE = LINE[2,MAX.LEN] REPEAT
127 LOOP WHILE LINE[LEN(LINE),1] = ' ' DO LINE =
LINE[1,LEN(LINE)-1] REPEAT
128 COMMENT = (LINE[1,1] = '*' OR LINE[1,1] = '!' OR LINE[1,4]
= 'REM ')
129 FLAG = 0
130 MAIN.LINE = TRIM(OCONV(LINE,'MCU'))
131 IF INDEX(MAIN.LINE,';',1) THEN
132 POINTER = INDEX(MAIN.LINE,';*',1)
133 IF POINTER THEN MAIN.LINE = TRIM(MAIN.LINE[1,POINTER-1])
134 POINTER = INDEX(MAIN.LINE,';!',1)
135 IF POINTER THEN MAIN.LINE= TRIM(MAIN.LINE[1,POINTER-1])
136 POINTER = INDEX(MAIN.LINE,'; *',1)
137 IF POINTER THEN MAIN.LINE = TRIM(MAIN.LINE[1,POINTER-1])
138 POINTER = INDEX(MAIN.LINE,'; !',1)
139 IF POINTER THEN MAIN.LINE= TRIM(MAIN.LINE[1,POINTER-1])
140 END
141 LEN.MAIN.LINE = LEN(MAIN.LINE)
142 BEGIN CASE
143 CASE (LINE[1,1] = '!' OR LINE[1,1] = '*') ; * AND
LINE[2,2] # ' '
144 FLAG = 6
145 CASE LINE[1,4] = 'REM ' ; * AND LINE[4,2] # ' '
146 FLAG = 6
147 CASE LABEL = '' AND COMMENT
148 C = 2
149 LOOP
150 NEXT.BYTE = MAIN.LINE[C,1]
151 UNTIL NEXT.BYTE = '' OR NEXT.BYTE = ' ' DO C = C + 1
REPEAT
152 LABEL = LINE[1,C-1]
153 LABEL = LABEL:SPACE(LSP-LEN(LABEL))
154 IF LABEL[LEN(LABEL),1] # ' ' THEN LABEL = LABEL:' '
155 MAIN.LINE = TRIM(MAIN.LINE[C+1,MAX.LEN])
156 FLAG = 6
157 CASE MAIN.LINE[1,04] = 'FOR ' AND INDEX(MAIN.LINE,'NEXT
',1)
158 CASE MAIN.LINE[1,04] = 'FOR ' AND
NOT(INDEX(MAIN.LINE,'NEXT ',1))
159 FLAG = 1
160 CASE MAIN.LINE[1,04] = 'LOOP' AND
INDEX(MAIN.LINE,'REPEAT',1)
161 CASE MAIN.LINE[1,04] = 'LOOP' AND
NOT(INDEX(MAIN.LINE,'REPEAT',1))
162 FLAG = 1
163 CASE MAIN.LINE[1,10] = 'BEGIN CASE'
164 FLAG = 4
165 CASE MAIN.LINE[1,08] = 'END CASE'
166 FLAG = 5
167 CASE MAIN.LINE[1,04] = 'CASE'
168 FLAG = 3
169 CASE MAIN.LINE[1,06] = 'UNTIL ' AND
INDEX(TRIM(MAIN.LINE),'DO REPEAT',1)
170 FLAG = 2
171 CASE MAIN.LINE[1,06] = 'UNTIL ' AND
INDEX(TRIM(MAIN.LINE),' DO ',1) AND INDEX(TRIM(MAIN.LINE),' REPEAT',1)
172 FLAG = 2
173 CASE MAIN.LINE[1,06] = 'UNTIL '
174 FLAG = 3
175 CASE MAIN.LINE[1,06] = 'WHILE ' AND
INDEX(TRIM(MAIN.LINE),'DO REPEAT',1)
176 FLAG = 2
177 CASE MAIN.LINE[1,06] = 'WHILE ' AND
INDEX(TRIM(MAIN.LINE),'REPEAT',1)
178 FLAG = 2
179 CASE MAIN.LINE[1,06] = 'WHILE '
180 FLAG = 3
181 CASE MAIN.LINE[1,06] = 'REPEAT'
182 FLAG = 2
183 CASE MAIN.LINE = 'END'
184 FLAG = 2
185 CASE MAIN.LINE[1,8] = 'END ELSE' OR MAIN.LINE[1,8] =
'END THEN'
186 IF MAIN.LINE[9,LEN(MAIN.LINE)-8] # '' THEN FLAG = 2
ELSE FLAG = 3
187 CASE MAIN.LINE[1,5] = 'NEXT '
188 FLAG = 2
189 CASE MAIN.LINE[LEN.MAIN.LINE-4,5] = ' THEN'
190 FLAG = 1
191 CASE MAIN.LINE[LEN.MAIN.LINE-4,5] = ' ELSE'
192 FLAG = 1
193 CASE MAIN.LINE[LEN.MAIN.LINE-6,7] = ' LOCKED'
194 IF INDEX(MAIN.LINE,'READ',1) THEN FLAG = 1
195 CASE MAIN.LINE[LEN.MAIN.LINE-8,9] = ' ON ERROR'
196 IF INDEX(MAIN.LINE,'READ',1) THEN FLAG = 1
197 IF INDEX(MAIN.LINE,'WRITE',1) THEN FLAG = 1
198 END CASE
199 BEGIN CASE
200 CASE FLAG = 1 ; * INDENT ON SUBSEQUENT LINES
201 SSP = SP
202 SP = SP + ID
203 CASE FLAG = 2 ; * OUTDENT ON THIS AND SUBSEQUENT
LINES
204 SSP = SP
205 SP = SP - ID
206 SPX = SPX - ID
207 CASE FLAG = 3 ; * OUTDENT THIS LINE ONLY
208 SPX = SPX - ID
209 CASE FLAG = 4 ; * INDENT DOUBLE ON SUBSEQUENT LINES
210 SSP = SP
211 SP = SP + ID + ID
212 CASE FLAG = 5 ; * OUTDENT DOUBLE ON THIS AND
SUBSEQUENT LINES
213 SSP = SP
214 TEMP = 2 * ID
215 SP = SP - TEMP
216 SPX = SPX - TEMP
217 CASE FLAG = 6 ; * PRINT WITH NO INDENTATION
218 SPX = 0
219 END CASE
220 IF MAIN.LINE[1,4] = '$INC' AND LABEL = '' THEN
221 NEW.LINE = LINE
222 END ELSE
223 NEW.LINE = LABEL:STR(' ',SPX-LEN(LABEL)):LINE
224 END
225 IF DISP THEN
226 IF SHOW.STRUCTURE AND SPX >= 3 THEN
227 FIRST.PART = LEN(LABEL) + SPX -3
228 DISP.LINE = NEW.LINE[1,FIRST.PART]:'.
':NEW.LINE[FIRST.PART+3,999]
229 END ELSE
230 DISP.LINE = NEW.LINE
231 END
232 PRINT LINE.NO LINE.JUST: DISP.LINE
233 END ELSE
234 IF NOT(MOD(LINE.NO,10)) THEN PRINT '^':
235 END
236 IF FILE.FLAG OR NOT(PRINTER.ON) THEN NEWITEM<LINE.NO> =
NEW.LINE
237 ITEM<LINE.NO> = ''
238 SPX = SP
239 REPEAT
240 IF PRINTER.ON THEN PRINT 'eoi ':LINE.NO'R%4'
241 ITEM.LEN = LEN(NEWITEM)
242 IF (ITEM.LEN < MAX.LEN) AND FILE.FLAG THEN
243 IF ITEM.LEN # 0 THEN WRITE NEWITEM ON FILE, NAME
244 END ELSE
245 LINE.NO = LINE.NO -1
246 PRINTER OFF
247 PRINT
248 PRINT LINE.NO 'R#5':' LINES PROCESSED!'
249 PRINT 'LENGTH OF PROCESSED ITEM IS ':ITEM.LEN 'R#5'
250 IF ITEM.LEN <= MAX.LEN THEN
251 IF NOT(PRINTER.ON) THEN
252 PRINT 'FILE ITEM? <Y>=YES ': ; INPUT REPLY
253 IF REPLY = YES THEN WRITE NEWITEM ON FILE, NAME
254 END
255 END ELSE
256 PRINT 'LENGTH OF ':ITEM.LEN 'R#5':' EXCEEDS THE MAXIMUM
FOR R91 AND APN'
257 PRINT 'Would you like to file item anyway? <Y>=Yes ':;
INPUT REPLY
258 IF REPLY = YES THEN WRITE NEWITEM ON FILE, NAME
259 END
260 END
261 END
262 NAME = ''
263 REPEAT

---

"Mike Preece" <mic...@preece.net> wrote in message
news:65a36f54-389b-4e39...@h2g2000vbd.googlegroups.com...

Tony Gravagno

unread,
Dec 16, 2009, 2:43:23 PM12/16/09
to
Mike Preece wrote:

>Brian Speirs wrote:
>> There is code for a BASIC formatter on PickWiki.
>

>Thanks Brian. I had a look. That code seems to be U2 specific and in
>need of mods before it could be used on mvBase.

Hi Mike - I hope you are well.

The BFormat program at PickWiki only has a couple lines that are
U2-specific, and these are easily replaced. Maybe you missed this
one:
http://www.pickwiki.com/cgi-bin/wiki.pl?BFormat

If mvBase doesn't come with its own code formatter then chances are
high that you're going to need to modify code written for another
platform. Welcome to the wonderful world of open source.

You can add mvBase-specific keywords to the list that the existing
BFormat program processes. That would be the simple way to make use
of that code. For extra credit, flag the code to be used in different
MV environments. I highly recommend using XBASIC for this purpose,
provided by Kevin King.
See: http://www.pickwiki.com/cgi-bin/wiki.pl?Freeware
So for example, U2 users wouldn't need to process UOPEN, and mvBase
users don't need to know anything about Functions.

If you do create something that is useful, I will also encourage you
to post it on PickWiki rather than (just) in a forum. Welcome to the
wonderful world of open source (again). Feel free to email
contributions to me and I'll post them to PickWiki.

I just took another look through the various utilities available at
PickWiki, including the many utilities linked from there to Tom
Phillips' website. There's some nice stuff out there. It would be
nice if some people took some time to tag those pages with keywords
for easier searches. And of course everyone is welcome to post code
or at least links to code or repositories of MV-related code. So for
example, there is a link to Tom's site but people can't search
PickWiki for something that is found on Tom's site.


Good luck bud.


Tony Gravagno
Nebula Research and Development
TG@ remove.pleaseNebula-RnD.com
remove.pleaseNebula-RnD.com/blog
Visit PickWiki.com! Contribute!
http://Twitter.com/TonyGravagno

sdavmor

unread,
Dec 16, 2009, 10:27:57 PM12/16/09
to
Ed Sheehan wrote:
> I've used this one for years. See if it works for you.
>
> Ed

Going back a very long way with this one, Ed!
--
Cheers, SDM -- a 21st Century Schizoid Man
Systems Theory music project: <www.systemstheory.net>
on MySpace: <www.myspace.com/systemstheory>
on GarageBand: <www.garageband.com/systemstheory>
on Last FM: <www.last.fm/music/Systems+Theory>
on CDBaby: <www.cdbaby.com/all/systemstheory>
get our MP3s free at <www.mikedickson.org.uk/codetalkers>
NP: nowt

Mike Preece

unread,
Dec 17, 2009, 8:03:44 AM12/17/09
to
On Dec 16, 7:43 pm, Tony Gravagno

Yes I foresaw that response Tony - and agree that PickWiki is a good
place for this type of thing.

Also - it would be really nice if someone was to make it so that PSPad
"understands" PickBasic in the same way that UltraEdit "understands"
UniData Basic. Btw - do you use PSPad or have you found something
better?

Kevin Powick

unread,
Dec 17, 2009, 8:46:07 AM12/17/09
to
On Dec 17, 8:03 am, Mike Preece <mich...@preece.net> wrote:

> Also - it would be really nice if someone was to make it so that PSPad
> "understands" PickBasic in the same way that UltraEdit "understands"
> UniData Basic. Btw - do you use PSPad or have you found something
> better?

I used PSPad for years, but switched to HippoEdit over a year ago.
It's not free, but it's really nice and I felt it was worth paying
for. Btw, I donated to PSPad because it's a good product too.

I've updated an existing language file for HippoEdit to be more BASIC
like, but not to the extent that all keywords are covered. If you're
only concerned about editing BASIC source files, then HippoEdit may
not be worth it.

However, it has a lot of features that make working with other file
types really great. For example, it can highlight code within code,
such as PHP and JavaScript within HTML. Very nice. It also has
predictive word/statement completion based on the language file
currently active and the frequency of keywords and variables typed. I
find it quite accurate and useful.

--
Kevin Powick

pschellenbach

unread,
Dec 17, 2009, 11:20:57 AM12/17/09
to
Hi Mike -

If I recall, there is a variant of BLIST on mvBase called BFORMAT,
which does the same formatting as BLIST, but updates the item instead.

Thanks,

Peter Schellenbach

Scott in Houston

unread,
Dec 17, 2009, 3:26:25 PM12/17/09
to
Accuterm has a great one built in the WED product. Using a full
screen editor is easier then ED as well.

Ed Sheehan

unread,
Dec 17, 2009, 4:00:21 PM12/17/09
to
It's been on a client's mvBase site since the 90's. I cant remember if I
wrote it or adapted it. But since the code there is from the 80's, it'll do
for that old legacy system.

Ed

"sdavmor" <sda...@fakeemailaddy.com> wrote in message
news:htOdnWuArZyiOLTW...@iswest.net...

frosty

unread,
Dec 17, 2009, 7:20:44 PM12/17/09
to
"Mike Preece" wrote:
> Also - it would be really nice if someone
> was to make it so that PSPad
> "understands" PickBasic in the same
> way that UltraEdit "understands"
> UniData Basic...

I've got a TextPad syntax file that defines
uniData BASIC; you might be able to tweak
that for PSPad, like I tweaked it from...
Notepad+ maybe (I forget.)


--
frosty


wjhonson

unread,
Dec 18, 2009, 1:11:10 AM12/18/09
to
Why is it, that the vast majority of Pick programmers don't seem to
understand what the Right Justification operator does?

What is the result of A= "THIS PHRASE" "R#5" ?

You get a cookie.

I simply find it much easier to understand then the convoluted code we
see above.

Additionally, since I'm griping evidently. What is a simpler way to
express NOT(A=B) ?

And finally there is no run-time advantage to
IF A or B or C or D Then E

versus
If A then E
If B then E
If C then E
If D then E

which is must easier to understand, even if it takes four lines :)
(AND it can be made a CASE!)

W.J. "In a bitchy mood"

Mike Preece

unread,
Dec 18, 2009, 4:29:32 AM12/18/09
to

I looked for B/LIST and BFORMAT first off. Not there.

Mike Preece

unread,
Dec 18, 2009, 4:30:45 AM12/18/09
to
On Dec 17, 8:26 pm, Scott in Houston <scott...@gmail.com> wrote:
> Accuterm has a great one built in the WED product.  Using a full
> screen editor is easier then ED as well.

Yes - I liked WED too. Unfornutately no such goodies with mvTerm.

RJ

unread,
Dec 18, 2009, 7:25:04 AM12/18/09
to

"wjhonson" <wjho...@aol.com> wrote in message
news:18a08e43-3c4b-4165...@o9g2000prg.googlegroups.com...


> Why is it, that the vast majority of Pick programmers don't seem to
> understand what the Right Justification operator does?
>
> What is the result of A= "THIS PHRASE" "R#5" ?

With QM, in most cases the best Pick-like available, it's not what you
expect. A very minor difference but a giant PITA when you are porting to
QM.

Homer L. Hazel

unread,
Dec 18, 2009, 9:30:05 AM12/18/09
to
Even though I don't really think you wanted an answers, I'm going to give
you some nonetheless.

"wjhonson" <wjho...@aol.com> wrote in message
news:18a08e43-3c4b-4165...@o9g2000prg.googlegroups.com...

> Why is it, that the vast majority of Pick programmers don't seem to
> understand what the Right Justification operator does?
>
> What is the result of A= "THIS PHRASE" "R#5" ?
>

D3 right justifies "THIS PHRASE" in a field of length 5, and you get
"HRASE".

> You get a cookie.
>
> I simply find it much easier to understand then the convoluted code we
> see above.
>
> Additionally, since I'm griping evidently. What is a simpler way to
> express NOT(A=B) ?
>

I generally use A#B. It seems more straight forward.

> And finally there is no run-time advantage to
> IF A or B or C or D Then E
>
> versus
> If A then E
> If B then E
> If C then E
> If D then E
>
> which is must easier to understand, even if it takes four lines :)
> (AND it can be made a CASE!)
>
> W.J. "In a bitchy mood"
>

Here's a quick and dirty program I wrote. I believe it does what you say.

A = "THIS PHRASE" "R#5"
CRT A
A = 1
B = 0
C = 0
D = 0
E = 22

CRT TIMEDATE()

FOR I = 1 TO 6000000
IF A OR B OR C OR D THEN E=77
NEXT I

CRT TIMEDATE()

FOR I = 1 TO 6000000
IF A THEN E = 77
IF B THEN E = 77
IF C THEN E = 77
IF D THEN E = 77
NEXT I

CRT TIMEDATE()
END

Here's the output when A = 1

:RUN BP TT1
HRASE
06:23:02 18 Dec 2009
06:23:11 18 Dec 2009 appears to be about 9 seconds
06:23:23 18 Dec 2009 looks like 12 seconds to me


Here's the output when D = 1

HRASE
06:26:09 18 Dec 2009
06:26:19 18 Dec 2009 this looks like 10 seconds
06:26:30 18 Dec 2009 and this is 11 seconds

So, my conclusion is that there is a very slight performance advantage to
the

IF A OR B OR C OR D THEN E

construct.

Larry Hazel

frosty

unread,
Dec 18, 2009, 1:53:16 PM12/18/09
to
"wjhonson" asked:

> Why is it, that the vast majority of Pick programmers don't seem to
> understand what the Right Justification operator does?
>
> What is the result of A= "THIS PHRASE" "R#5" ?
>
> You get a cookie.

OK, I'll bite: How is the string "HRASE" a cookie?

--
frosty


Larry

unread,
Dec 18, 2009, 3:36:02 PM12/18/09
to

frosty,

I think he meant that if you get the proper answer
(I almost said RIGHT answer) he will give you a
cookie! I also got HRASE which agrees with you.

I prefer oatmeal cookies! 8>)


Larry Hazel

Peter McMurray

unread,
Dec 18, 2009, 4:36:45 PM12/18/09
to
Hi
I think that you will find that IF A OR B OR C OR D THEN E = 42 is treated
like a CASE statement and terminates at the first correct answer. This is
unlike many other languages that have drop-through logic for CASE statements
and require a specific termination as soon as you hit a correct answer.
Whereas

If A then E
If B then E
If C then E
If D then E
Executes every single test.
However my major objection is the use of the If A then E construct under any
circumstances. It is an unreliable statement and the interpretation depends
on the implementation. It is always preferable to use a genuine equality
statement such as
IF A NE 0 THEN E = 42 ELSE E = 0 or
IF A = 0 THEN E = 42 ELSE E = 0
there is no ambiguity and it is patently obvious what the program is doing.
Plus you do not accidentally wind up with E as unassigned later on.
Peter McMurray


"Homer L. Hazel" <home...@coxSPAM.net> wrote in message
news:QlMWm.101653$Wf2....@newsfe23.iad...

Homer L. Hazel

unread,
Dec 19, 2009, 11:36:25 AM12/19/09
to
Peter,

I totally agree. I don't generally use these methods, but I wanted to test
the premise.

I agree that the IF A OR B OR C OR D THEN E = 42 terminates with the first
match. That's why I ran it twice, once with A being set to 1 and once with
D
being set to 1. The time difference, although slight, indicates that there
is more
going on when D is 1 than when A is one.

I sometimes have problems with unassigned variables, but not because I don't
consider every option when inside the loops or whatever, but with some
boundary condition that should not exist. They get me all of the time.

Larry Hazel

"Peter McMurray" <excal...@bigpond.com> wrote in message
news:NBSWm.63131$ze1....@news-server.bigpond.net.au...

x

unread,
Dec 19, 2009, 1:35:30 PM12/19/09
to
> And finally there is no run-time advantage to
> IF A or B or C or D Then E
> versus
> If A then E
> If B then E
> If C then E
> If D then E

It's not the speed, it's the result.
Let's see:


A = 1
B = 0

C = -3
D = 14
E = 1

IF A OR B OR C OR D THEN E = E + 3
Result: E = 4

IF A THEN E = E + 3
IF B THEN E = E + 3
IF C THEN E = E + 3
IF D THEN E = E + 3
Result: E = 10

frosty

unread,
Dec 19, 2009, 1:57:51 PM12/19/09
to
>>wjhonson:

>>> Why is it, that the vast majority of Pick programmers don't seem to
>>> understand what the Right Justification operator does?
>>> What is the result of A= "THIS PHRASE" "R#5" ?
>>> You get a cookie.

>frosty:


>>OK, I'll bite: How is the string "HRASE" a cookie?

Larry:


>
>I think he meant that if you get the proper answer
>(I almost said RIGHT answer) he will give you a
>cookie! I also got HRASE which agrees with you.
>I prefer oatmeal cookies! 8>)

Thanks for clearing that up. Oatmeal are good.
Raisins, nuts, chocolate chips...

What I don't get is this: what other result, other
than 'HRASE', might the vast majority of Pick
programmers expect from "THIS PHRASE" "R#5" ???

--
frosty


Tony Gravagno

unread,
Dec 19, 2009, 2:54:22 PM12/19/09
to
Mike Preece wrote:
>it would be really nice if someone was to make it so that PSPad
>"understands" PickBasic in the same way that UltraEdit "understands"
>UniData Basic. Btw - do you use PSPad or have you found something
>better?


I still use PSPad for all text except MV BASIC. I have written some
addins for PSPad but no syntax highlighter.

I use AccuTerm WED when I'm doing a lot of BASIC work. Unfortunately
WED is quite limited in how it does syntax checking and I've created
an extensive set of platform-specific keywords to augment its
defaults. (I think there is a discussion of this in the AccuTerm
forum, some of us may have published our lists, I don't recall.)

I was going to publish a new low-cost graphical MV editor with client
and server features not found anywhere else, but the investment/return
ratio was too high for this frugal market. (No need to belabor how
this community stiffles innovation and thus hinders its own progress).

Brian Leach has an editor called mvDeveloper which is available as
Lite freeware and a more powerful commercial version. I believe
mvDeveloper is only available for U2 and QM but he and I have
discussed collaboration to create a port for other platforms -
inquiries welcome.
http://www.brianleach.co.uk/pages/mvdeveloper.htm

This isn't much help I'm afraid. The implied desire for "free"
precludes many solutions.

T

Tony Gravagno

unread,
Dec 19, 2009, 2:54:21 PM12/19/09
to
I'm just wondering what in blazes sparked this rant in the middle of a
discussion about text editors when there was no mention of
justification or conditional statements.

frosty

unread,
Dec 19, 2009, 3:07:09 PM12/19/09
to
"Tony Gravagno" <address.i...@removethis.com.invalid> wrote in
message news:l39qi59nckotejp76...@4ax.com...

> I'm just wondering what in blazes sparked this rant in the middle of a
> discussion about text editors when there was no mention of
> justification or conditional statements.

Dunno... moon's not full.

--
frosty


Kevin Powick

unread,
Dec 19, 2009, 7:44:53 PM12/19/09
to
On Dec 19, 1:35 pm, x <lucian_p...@yahoo.com> wrote:

> It's not the speed, it's the result.
> Let's see:
> A = 1
> B = 0
> C = -3
> D = 14
> E = 1
>
> IF A OR B OR C OR D THEN E = E + 3
> Result: E = 4
>
> IF A THEN E = E + 3
> IF B THEN E = E + 3
> IF C THEN E = E + 3
> IF D THEN E = E + 3
> Result: E = 10

Like the OP of this "rant", you have made an assumption on what
exactly "E" represents.

Other examples of working or non-working code would be:

THEN GOTO xxx (should work)
THEN GOSUB xxx (probably causes problems)

Maintenance headaches would also need consideration if "E" represented
a multiple statement code block.

Generally, I would say that what the OP posted as a better construct
than multiple ORs is actually poor coding. One should use either "old
school" nested IF/THEN/ELSE or, more "modern", CASE statements.

--
Kevin Powick

wjhonson

unread,
Dec 19, 2009, 9:13:27 PM12/19/09
to
On Dec 19, 11:54 am, Tony Gravagno

It's in there Tony.
Look for something like A[Len(A)-5,6]
which is, I believe identical to
A"R#6"

Charlie Noah

unread,
Dec 20, 2009, 9:10:32 AM12/20/09
to

Will,

I've been watching this thread with interest, and was content to keep
my mouth shut, since I moved from AP (never got into D3) to Jbase many
years ago. however, I have to demonstrate where you went off the rails
here.

If A = '12345678', then A[LEN(A)-5,6] = '345678' AND A 'R#6' =
'345678'.
However, if

Charlie Noah

unread,
Dec 20, 2009, 9:27:19 AM12/20/09
to

My reply decided to post itself before I was finished - I couldn't
possibly have hit a wrong key!
Anyway,

If A = '12345678', then A[LEN(A)-5,6] = '345678' AND A 'R#6' =
'345678'.

However, if A = '678', then A[LEN(A)-5,6] = '78' AND A 'R#6' = '
678'.
Probably not the desired result.

A different construct:
If A = '12345678', then A[-6,6] = '678'.
If A = '678', then A[-6,6] = '678'.

If what you want is the rightmost 6 characters, perhaps the last
construct is the way to go.

Charlie Noah
Sr. Systems Analyst
Inland Truck Parts

Paddy

unread,
Dec 21, 2009, 11:56:56 AM12/21/09
to
On Dec 16, 4:28 am, Mike Preece <mich...@preece.net> wrote:
> Hello
>
> Can someone post Basic source code to format basic source code so that
> I can copy and paste it please.
>
> I am on a mvBase site without admin rights to my workstation and so am
> unable to install UltraEdit or any of the other non-Pick programs
> capable of formatting PickBasic code. The mvBase version of BLIST
> seems to be able to print but not update. I thought I had a Basic code
> formatter somewhere but can't find it right now so would be grateful
> if someone could post the code here.

You could use BLIST and send it to the spooler, then use SP-EDIT and
direct it to a file with F, the edit out the RUNOFF .BP stuff at the
top and bottom. It will work.

chandru

unread,
Dec 27, 2009, 8:42:12 PM12/27/09
to
A oddly picky programmer wrote that he didn't like:

>IF A or B or C or D Then E
> versus
>If A then E
>If B then E
>If C then E
>If D then E

Others have pointed out the efficiency of the first syntax. I however,
have a stronger objection (efficiency being of little importance):

The four line IF is just plain confusing. At the very least, use
ELSE's after each IF, not just for efficiency but because that way
it's more readable. Or a Case.

Incidentally, in javascript one often uses:

if( object && object.whatever == 1 )

when 'object' may by undefined, in which case the if terminates at the
test of 'object' and does not get to the object.whatever, which will
fail if it is evaluated.

Chandru

wjhonson

unread,
Dec 28, 2009, 4:00:44 AM12/28/09
to
On Dec 20, 6:27 am, Charlie Noah <cwn...@comcast.net> wrote:


>
> If A = '12345678', then A[LEN(A)-5,6] = '345678' AND A 'R#6' =
> '345678'.
> However, if A = '678', then A[LEN(A)-5,6] = '78' AND A 'R#6' = '
> 678'.
> Probably not the desired result.
>
> A different construct:
> If A = '12345678', then A[-6,6] = '678'.
> If A = '678', then A[-6,6] = '678'.
>
> If what you want is the rightmost 6 characters, perhaps the last
> construct is the way to go.
>
> Charlie Noah
> Sr. Systems Analyst

> Inland Truck Parts- Hide quoted text -
>

It's true that the two constructs do not always give you the same
answer, however you have to review what the program is attempting to
do at that juncture.

The line in English would be something like "Does this line end in the
keyword THEN ?"
So two results differing from each other, but both yielding a False
don't really matter in the long run.
What matters is only a true result, the Else phrase being empty or
falling to a nested If set.

So I still submit that in this particular case, Line"R#5" = " THEN" is
clearer, shorter, and cleaner.

As for Chandru's response below, of course I shortened the original
offending line, because I was simply trying to point out one aspect of
it, not all aspects. The original line I was offeneded by was so long
it caused line-wrap. I hate line-wrap.

We have to remember that the most precious resource is the
programmer's eyes and brains and not yours. The guy who comes after
you. They are the ones who have to try to understand what your
program is doing, and how to fix it quick while the loading dock is
waiting. So programs should be as clean, clear and simple as
possible. That's the way I try to program. You'll almost never be
the last or only person to try to fix your code.

Will

frosty

unread,
Dec 28, 2009, 11:55:21 AM12/28/09
to
chandru wrote in message
news:2c0254b1-191d-4f67...@m38g2000yqd.googlegroups.com...

A oddly picky programmer wrote that he didn't like:

>IF A or B or C or D Then E
> versus
>If A then E
>If B then E
>If C then E
>If D then E

Others have pointed out the efficiency of the first syntax. I however,
have a stronger objection (efficiency being of little importance):

The four line IF is just plain confusing. At the very least, use
ELSE's after each IF, not just for efficiency but because that way
it's more readable. Or a Case.

Incidentally, in javascript one often uses:

if( object && object.whatever == 1 )

when 'object' may by undefined, in which case the if terminates at the
test of 'object' and does not get to the object.whatever, which will
fail if it is evaluated.

Chandru

JavaScript is interpreted,but any competent compiler
will do that at compile time.

No sense evaluating B, C or D, if not A!

--
frosty


0 new messages