dbTalk Databases Forums  

MVBASIC FORMATTING QUESTION

comp.databases.pick comp.databases.pick


Discuss MVBASIC FORMATTING QUESTION in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MVGuru
 
Posts: n/a

Default MVBASIC FORMATTING QUESTION - 12-12-2005 , 06:03 PM






Is there a format command or some kind of formatting for a basic
program?


Reply With Quote
  #2  
Old   
Mark Brown
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-12-2005 , 06:19 PM






I think what you are looking for is the BLIST or B/List command. One, iirc,
was a verb and the other was a Pick Basic program. Both had options for
printing and, I believe, writing the program back into the library file.

One or the other should be available on your system. If not, the PB version
is pretty much "public domain" so I guess we could post it here if you needs
it.

Mark Brown

"MVGuru" <theo (AT) violetvortex (DOT) com> wrote

Quote:
Is there a format command or some kind of formatting for a basic
program?




Reply With Quote
  #3  
Old   
Ricky
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-12-2005 , 07:20 PM




"MVGuru" <theo (AT) violetvortex (DOT) com> wrote

Quote:
Is there a format command or some kind of formatting for a basic
program?
This MD item called 'F' executes the formatter below
The syntax from TCL is:
:F BASIC.PROGRAM.NAME <enter>

001 PQ
002 HFORMAT.PROG
003 P

FORMAT.PROG
001 * COPYRIGHT 1985/1998 - RICHARD GINSBURG
002 * ALL RIGHTS RESERVED
003 * COMPASS - RELEASE 7.7
004 * This Program embodies confidential information proprietary to
005 * Richard Ginsburg and shall not be reproduced, copied, disclosed, or
006 * transferred in any manner except under written agreement executed by
007 * Richard Ginsburg. This program is an unpublished work fully
008 * protected by the United States copyright laws and is considered a
trade
009 * secret of Richard Ginsburg.
010 PROCREAD KEY ELSE STOP
011 KEY=TRIM(FIELD(KEY,' ',2))
012 EQU BELL TO CHAR(7),FM TO CHAR(254)
013 PROMPT ''
014 FILE='PROG-LIB'
015 OPEN FILE TO F.FILE ELSE
016 PRINT;PRINT;PRINT "Cannot open '":FILE:"' file. Hit
<ENTER>":;INPUT A,2
017 STOP
018 END
019 READV TEST FROM F.FILE,KEY,1 ELSE STOP
020 SP=6;ID=3;SPX=6;CFLG=0;BFR=0;LINE.NO=0
021 LOOP
022 LINE.NO=LINE.NO+1
023 READV LN FROM F.FILE,KEY,LINE.NO ELSE LN=''
024 UNTIL LN='' DO
025 GOSUB 1000
026 LABEL='';L=1;X=LN 'R#5'
027 IF NUM(LN[1,1]) THEN
028 LOOP
029 L=L+1
030 WHILE NUM(LN[L,1]) DO
031 REPEAT
032 LABEL=LN[1,L-1]
033 LN=LN[L,32767]
034 GOSUB 1000
035 END
036 CMND=FIELD(LN,' ',1)
037 BEGIN CASE
038 CASE LN[1,1]='*' OR LN[1,1]='!' OR LN[1,3]='REM'
039 SPX=0
040 CASE (CMND='FOR' AND INDEX(LN,'NEXT',1)=0) OR CMND='BEGIN'
OR CMND='LOOP'
041 IF CMND='LOOP' AND X='EPEAT' THEN NULL ELSE SP=SP+3
042 IF CMND='BEGIN' THEN BFR=0
043 CASE CMND='CASE'
044 IF BFR THEN
045 IF CFLG THEN
046 SPX=SPX-ID;SP=SPX;CFLG=0
047 END
048 END ELSE
049 BFR=1;CFLG=0
050 END
051 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
052 CASE CMND='END' OR CMND='NEXT' OR CMND='WHILE' OR
CMND='UNTIL' OR CMND='REPEAT'
053 SPX=SPX-ID
054 IF (CMND='END' AND X#' ELSE') OR X='EPEAT' OR CMND='NEXT'
THEN SP=SPX
055 IF X=' CASE' THEN
056 IF CFLG THEN
057 CFLG=0;SPX=SPX-ID
058 END
059 SP=SPX
060 END
061 CASE X=' THEN' OR X=')THEN' OR X='>THEN' OR X=' ELSE' OR
X=')ELSE' OR X='>ELSE'
062 SP=SP+ID
063 CASE 1;IF BFR THEN CFLG=1 ELSE CLFG=0
064 END CASE
065 NEW.LINE=LABEL:STR(' ',SPX-LEN(LABEL)):LN
066 PRINT NEW.LINE
067 WRITEV NEW.LINE ON F.FILE,KEY,LINE.NO
068 SPX=SP
069 REPEAT
070 STOP
071 1000* SUBROUTINE TO TRIM FRONT AND BACK OF LINE
072 *
073 LOOP UNTIL LN[1,1]#" " DO
074 LN=LN[2,32767]
075 REPEAT
076 LOOP UNTIL LN[LEN(LN),1]#" " DO
077 LN=LN[1,LEN(LN)-1]
078 REPEAT
079 RETURN
080 END




Reply With Quote
  #4  
Old   
Luke Webber
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-12-2005 , 08:55 PM



Mark Brown wrote:
Quote:
I think what you are looking for is the BLIST or B/List command. One, iirc,
was a verb and the other was a Pick Basic program. Both had options for
printing and, I believe, writing the program back into the library file.

One or the other should be available on your system. If not, the PB version
is pretty much "public domain" so I guess we could post it here if you needs
it.
Or BFORMAT. Be sure to read the doco, because it tels you how to set the
default indentation settings for you system.

Cheers,
Luke


Reply With Quote
  #5  
Old   
Tony Gravagno
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-12-2005 , 10:03 PM



Theo - for your mvBASE system, yes, BLIST is the right command. The D
and T options are available for special operations - info should be
available in your mvBASIC documentation. For D3 the BFORMAT command
is available and can be customized very nicely using control records.
(Man, I wish other D3 functions worked like that!)

If you use AccuTerm for any MV DBMS, wED (Windows EDitor) does a nice
job of formatting as well.

No offense Theo, but I don't know if I'd use a moniker like MVGuru to
post a noob question like this. From someone named MVGuru I'd expect
something more like "I just wrote a new Java compiler in BASIC and I'd
like to know if there is existing BASIC code to format my Java or if I
should just write my own in assembler."

HTH
T

"Mark Brown" wrote:

Quote:
I think what you are looking for is the BLIST or B/List command. One, iirc,
was a verb and the other was a Pick Basic program. Both had options for
printing and, I believe, writing the program back into the library file.

One or the other should be available on your system. If not, the PB version
is pretty much "public domain" so I guess we could post it here if you needs
it.

Mark Brown

"MVGuru" wrote
Is there a format command or some kind of formatting for a basic
program?



Reply With Quote
  #6  
Old   
frosty
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-13-2005 , 12:00 PM



Tony Gravagno wrote:
[snip]
Quote:
No offense Theo, but I don't know if I'd use a moniker like MVGuru to
post a noob question like this. From someone named MVGuru I'd expect
something more like...
Pwned!!! =`8^O

--
fr05+y




Reply With Quote
  #7  
Old   
B Faux
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-13-2005 , 01:03 PM




"Ricky" <rginsburg (AT) yahoo (DOT) com> wrote

Quote:
"MVGuru" <theo (AT) violetvortex (DOT) com> wrote in message
news:1134432201.465082.246160 (AT) f14g2000cwb (DOT) googlegroups.com...
Is there a format command or some kind of formatting for a basic
program?
This MD item called 'F' executes the formatter below
The syntax from TCL is:
:F BASIC.PROGRAM.NAME <enter

001 PQ
002 HFORMAT.PROG
003 P

FORMAT.PROG
001 * COPYRIGHT 1985/1998 - RICHARD GINSBURG
002 * ALL RIGHTS RESERVED
003 * COMPASS - RELEASE 7.7
004 * This Program embodies confidential information proprietary to
005 * Richard Ginsburg and shall not be reproduced, copied, disclosed, or
006 * transferred in any manner except under written agreement executed
by
007 * Richard Ginsburg. This program is an unpublished work fully
008 * protected by the United States copyright laws and is considered a
trade
009 * secret of Richard Ginsburg.
010 PROCREAD KEY ELSE STOP
011 KEY=TRIM(FIELD(KEY,' ',2))
012 EQU BELL TO CHAR(7),FM TO CHAR(254)
013 PROMPT ''
014 FILE='PROG-LIB'
015 OPEN FILE TO F.FILE ELSE
016 PRINT;PRINT;PRINT "Cannot open '":FILE:"' file. Hit
ENTER>":;INPUT A,2
017 STOP
018 END
019 READV TEST FROM F.FILE,KEY,1 ELSE STOP
020 SP=6;ID=3;SPX=6;CFLG=0;BFR=0;LINE.NO=0
021 LOOP
022 LINE.NO=LINE.NO+1
023 READV LN FROM F.FILE,KEY,LINE.NO ELSE LN=''
024 UNTIL LN='' DO
025 GOSUB 1000
026 LABEL='';L=1;X=LN 'R#5'
027 IF NUM(LN[1,1]) THEN
028 LOOP
029 L=L+1
030 WHILE NUM(LN[L,1]) DO
031 REPEAT
032 LABEL=LN[1,L-1]
033 LN=LN[L,32767]
034 GOSUB 1000
035 END
036 CMND=FIELD(LN,' ',1)
037 BEGIN CASE
038 CASE LN[1,1]='*' OR LN[1,1]='!' OR LN[1,3]='REM'
039 SPX=0
040 CASE (CMND='FOR' AND INDEX(LN,'NEXT',1)=0) OR CMND='BEGIN'
OR CMND='LOOP'
041 IF CMND='LOOP' AND X='EPEAT' THEN NULL ELSE SP=SP+3
042 IF CMND='BEGIN' THEN BFR=0
043 CASE CMND='CASE'
044 IF BFR THEN
045 IF CFLG THEN
046 SPX=SPX-ID;SP=SPX;CFLG=0
047 END
048 END ELSE
049 BFR=1;CFLG=0
050 END
051 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
052 CASE CMND='END' OR CMND='NEXT' OR CMND='WHILE' OR
CMND='UNTIL' OR CMND='REPEAT'
053 SPX=SPX-ID
054 IF (CMND='END' AND X#' ELSE') OR X='EPEAT' OR
CMND='NEXT' THEN SP=SPX
055 IF X=' CASE' THEN
056 IF CFLG THEN
057 CFLG=0;SPX=SPX-ID
058 END
059 SP=SPX
060 END
061 CASE X=' THEN' OR X=')THEN' OR X='>THEN' OR X=' ELSE' OR
X=')ELSE' OR X='>ELSE'
062 SP=SP+ID
063 CASE 1;IF BFR THEN CFLG=1 ELSE CLFG=0
064 END CASE
065 NEW.LINE=LABEL:STR(' ',SPX-LEN(LABEL)):LN
066 PRINT NEW.LINE
067 WRITEV NEW.LINE ON F.FILE,KEY,LINE.NO
068 SPX=SP
069 REPEAT
070 STOP
071 1000* SUBROUTINE TO TRIM FRONT AND BACK OF LINE
072 *
073 LOOP UNTIL LN[1,1]#" " DO
074 LN=LN[2,32767]
075 REPEAT
076 LOOP UNTIL LN[LEN(LN),1]#" " DO
077 LN=LN[1,LEN(LN)-1]
078 REPEAT
079 RETURN
080 END

Wow;

When I said 'trivial' (see first response post) I didn't expect less than a
hundred lines (including comments)!
Impressive Ricky, but we still do not know what environment we're working
with, do we? Looks pretty generic though..nice 'n tight...well done, you
gonna allow him to use it, (see top of prog)?

BFaux




Reply With Quote
  #8  
Old   
Simon Verona
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-13-2005 , 01:17 PM



I used to have a program that would BLIST the program item , capture the
output and reformat back into the original data, giving some very nice
formatting..

Regards
Simon
"MVGuru" <theo (AT) violetvortex (DOT) com> wrote

Quote:
Is there a format command or some kind of formatting for a basic
program?




Reply With Quote
  #9  
Old   
B Faux
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-13-2005 , 03:45 PM



[snip]
Quote:
This MD item called 'F' executes the formatter below
The syntax from TCL is:
:F BASIC.PROGRAM.NAME <enter

001 PQ
002 HFORMAT.PROG
003 P

FORMAT.PROG
001 * COPYRIGHT 1985/1998 - RICHARD GINSBURG
002 * ALL RIGHTS RESERVED
[snip]
007 * Richard Ginsburg. This program is an unpublished work fully
008 * protected by the United States copyright laws and is considered a
trade
009 * secret of Richard Ginsburg.
010 PROCREAD KEY ELSE STOP
011 KEY=TRIM(FIELD(KEY,' ',2))
[snip]

'PROCREAD'??!!?? Kill the PROC die PROC die!!! (pounding the keyboard)

- consider using 'SENTENCE' (or equivalent) command at top of prog and
cataloging the compiled code.

<ex>
newvalue=SENTENCE()
IF INDEX(newvalue," ",2) THEN; * Don't neglect your 'true/false' issues here
*
* at least two spaces in sentence *
filename=FIELD(newvalue," ",2); * Second space delimited value *
progname=FIELD(newvalue," ",3); * Third space delimited value *
END ELSE
* Only one space or no space *
filename='DEFAULT.FILE'
progname=FIELD(newvalue," ",2);* Only second entered value is important *
END
* Appropriate errors if either filename or progname are invalid, etc. *
<ex\>

Then at TCL you simply enter: "FORMAT.PROG PROGNAME" or "FORMAT.PROG
FILENAME PROGNAME" and the PROC goes away, as it should (screaming in pain,
trailing bloody body parts... sorry got carried away there - I love PROC!)

BFaux




Reply With Quote
  #10  
Old   
frosty
 
Posts: n/a

Default Re: MVBASIC FORMATTING QUESTION - 12-13-2005 , 04:03 PM



B Faux wrote:
Quote:
[snip]
This MD item called 'F' executes the formatter below
The syntax from TCL is:
F BASIC.PROGRAM.NAME <enter

001 PQ
002 HFORMAT.PROG
003 P

FORMAT.PROG
001 * COPYRIGHT 1985/1998 - RICHARD GINSBURG
002 * ALL RIGHTS RESERVED [snip]
007 * Richard Ginsburg. This program is an unpublished work fully
008 * protected by the United States copyright laws and is
considered a trade
009 * secret of Richard Ginsburg.
010 PROCREAD KEY ELSE STOP
011 KEY=TRIM(FIELD(KEY,' ',2)) [snip]

'PROCREAD'??!!?? Kill the PROC die PROC die!!! (pounding the
keyboard)
- consider using 'SENTENCE' (or equivalent) command at top of prog and
cataloging the compiled code.

ex
newvalue=SENTENCE()
IF INDEX(newvalue," ",2) THEN
[snip]
I'd put a TRIM() around SENTENCE() first.
At least on uniData (@SENTENCE) the 'extra'
blanks are preserved.

--
fro$ty




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.