dbTalk Databases Forums  

Best way to paginate macros in D3?

comp.databases.pick comp.databases.pick


Discuss Best way to paginate macros in D3? in the comp.databases.pick forum.



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

Default Best way to paginate macros in D3? - 02-14-2007 , 01:26 PM






I'm a Pick newbie, using D3. I've figured out how to write macros, but
I'm stuck trying to figure out how to best paginate their output. I
figured the easiest approach was to stick some sort of input statement
into the macro to wait for a keystroke after each screenful. While I
couldn't find a way to do this directly from the macro, I wrote a short
'waitforchar' BASIC program which works fairly well:

waitforchar
001 * Wait for one character to be entered
002 PRINT "Press a key to continue: ":
003 IN CHARACTER
004 STOP

It's used in a macro like this
sample-macro
001 N
002 ...produce first screen of data...
003 run bp waitforchar
004 ...produce second screen of data...
005 run bp waitforchar
006 ...etc...

Is there a better way to paginate macro output? I notice that many of
the system commands in the dm account are implemented in BASIC, but have
some sort of 'wrapper' around them. What is the function of this
wrapper -- I haven't been able to decipher it?

For example, the 'list-users' command in the dm account seems to be
defined as shown below in "dm,,", and the BASIC code for the command is
located in "dm,bp,".

list-users
001 VR
002 3
9
003 F
004 dm,bp, list-users

How do I interpret this definition, line-by-line? Line #2 appears to
contain a multivalued entry, if I'm reading it correctly. How to you
enter these using the Editor or Update processor? 'list-item' displays
line 2 as:

002 3]9

Any help would be appreciated...

Reply With Quote
  #2  
Old   
Chandru Murthi
 
Posts: n/a

Default Re: Best way to paginate macros in D3? - 02-14-2007 , 02:07 PM






I assume your program is in BASIC. If so, don't use this approach. It's tied
in to the screen size and any time you want to make a change it'll be
painful.

Firstly, Pick has the TERM verb which sets the page width/depth etc: eg:
TERM 79,23 for a screen.
Next, use the HEADING statement in BASIC eg HEADING "This is the top" and
FOOTING "...whatever..enter any key to continue". This turns on pagination.
Then just use PRINT to output your data.
When a page if full, the Footing will print and wait.
You can run the program with the (N) option to output continuously.

If you run the same program to the printer, it will fill pages according to
the current print page size (also set by TERM)

Don't change verbs in MD! You may copy them to new ones: ie COPY MD
list-users TO: LU

Chandru

"Bert Sierra" <bsierra (AT) fanncontracting (DOT) com> wrote

Quote:
I'm a Pick newbie, using D3. I've figured out how to write macros, but
I'm stuck trying to figure out how to best paginate their output. I
figured the easiest approach was to stick some sort of input statement
into the macro to wait for a keystroke after each screenful. While I
couldn't find a way to do this directly from the macro, I wrote a short
'waitforchar' BASIC program which works fairly well:

waitforchar
001 * Wait for one character to be entered
002 PRINT "Press a key to continue: ":
003 IN CHARACTER
004 STOP

It's used in a macro like this
sample-macro
001 N
002 ...produce first screen of data...
003 run bp waitforchar
004 ...produce second screen of data...
005 run bp waitforchar
006 ...etc...

Is there a better way to paginate macro output? I notice that many of
the system commands in the dm account are implemented in BASIC, but have
some sort of 'wrapper' around them. What is the function of this
wrapper -- I haven't been able to decipher it?

For example, the 'list-users' command in the dm account seems to be
defined as shown below in "dm,,", and the BASIC code for the command is
located in "dm,bp,".

list-users
001 VR
002 3
9
003 F
004 dm,bp, list-users

How do I interpret this definition, line-by-line? Line #2 appears to
contain a multivalued entry, if I'm reading it correctly. How to you
enter these using the Editor or Update processor? 'list-item' displays
line 2 as:

002 3]9

Any help would be appreciated...



Reply With Quote
  #3  
Old   
Scott Ballinger
 
Posts: n/a

Default Re: Best way to paginate macros in D3? - 02-14-2007 , 02:39 PM



Bert,

There is a "prompt" verb specifically for use in macros that does the
same thing as your "waitforchar", except that it requires "c" or "q"
and allows for a text string to be output first.

Look up "prompt" on www.d3ref.com (the entry you want is the last one,
"tcl.prompt.")

You have realized the biggest limitation of macros: no input and no
branching. As Chandru mentioned, wrapping your reports in basic allows
much more control, including pausing and pagination, as well as
prompting for things like date ranges, screen vs. printer, etc.

/Scott Ballinger
Pareto Corporation
Edmonds WA USA
206 713 6006


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

Default Re: Best way to paginate macros in D3? - 02-15-2007 , 12:32 AM



Bert Sierra wrote:

Quote:
I'm a Pick newbie, using D3.
Welcome to the party, hors d'oeuvres are in that thread, rest area is
in this thread, look out for when the fights break out, and just
ignore the guy over in that thread... LOL


Quote:
I've figured out how to write macros, but
I'm stuck trying to figure out how to best paginate their output.
When you say "paginate" I think you have a couple of us confused. Are
you sending a stream of output, like printer output, and you want to
paginate between those pages as well as between programs? Or do you
have normal character screens, executed one after another, and you
just want to pause between executing each one?

Personally I wouldn't recommend changing existing BASIC code as that
would probably break it.

Quote:
I figured the easiest approach was to stick some sort of input statement
into the macro to wait for a keystroke after each screenful. While I
couldn't find a way to do this directly from the macro, I wrote a short
'waitforchar' BASIC program which works fairly well:

waitforchar
001 * Wait for one character to be entered
002 PRINT "Press a key to continue: ":
003 IN CHARACTER
004 STOP

It's used in a macro like this
sample-macro
001 N
002 ...produce first screen of data...
003 run bp waitforchar
004 ...produce second screen of data...
005 run bp waitforchar
006 ...etc...

Is there a better way to paginate macro output?
You could put an M rather than N in attribute 1 of your macro and that
will accomplish something close to what you want.
001 M
002 time
003 who
004 listu
This will display each command and pause _before_ executing.

Other than that, the 'prompt' program should work for you as Scott
mentioned.

(Can anyone figure out why RD chose to execute a DISPLAY in the Prompt
program rather than just using CRT?)


Quote:
I notice that many of
the system commands in the dm account are implemented in BASIC, but have
some sort of 'wrapper' around them. What is the function of this
wrapper -- I haven't been able to decipher it?
That wrapper is called a Catalog entry. It's just like a shortcut on
your Windows desktop. Rather than putting programs on the desktop (or
inthe master dictionary), the programs are in a programs file, and a
small pointer is provided that will execute that program.

When you edit a program it's in a program file.
When you compile it the source doesn't change but object code is put
into the dictionary of the file (just as a matter of convention).
To execute you can RUN FILENAME PROGNAME, or you can Catalog the
program using CATALOG FILENAME PROGNAME, which will setup one of these
shortcuts to the object code. Then all you need to do is type the
PROGNAME to execute it.

A macro allows you to do something similar but much more. An
equivalent macro named PROGNAME would be:
001 N
002 RUN FILENAME PROGNAME

The rule of thumb is to use catalog entries for individual programs
and macros to execute more than one function in a series.


Quote:
For example, the 'list-users' command in the dm account seems to be
defined as shown below in "dm,,", and the BASIC code for the command is
located in "dm,bp,".

list-users
001 VR
002 3
9
003 F
004 dm,bp, list-users

How do I interpret this definition, line-by-line? Line #2 appears to
contain a multivalued entry, if I'm reading it correctly. How to you
enter these using the Editor or Update processor? 'list-item' displays
line 2 as:

002 3]9

Any help would be appreciated...
These lines are almost never maintained manually - it's "internal"
voodoo. The important thing is, if you execute a command from the
command line (TCL) and you want to know what you're executing, if you
see that same structure then you're looking at a pointer to a program.
Attribute 1 in a dictionary or master dictionary tell the system how
to process a given item. For example, you have found that N (and now
M) tell the system to process the rest of the item like a Macro.
You'll find that an A or S in atb 1 mean the item is structured like
an Attribute definition, or a Synonym of an attrubute definition (they
work exactly the same BTW). A PQ item is a Proc (short for Procedure,
which is another kind of macro). A Q item is a Q-pointer which is an
alternate means of referencing a file. A D-pointer is a primary file
definition and should never be modified until you really understand
the environment. Other items are generally reserved for the system -
and almost none of them should be modified manually ... yet.

Please do yourself a favor and try to set yourself up with a test
account (database) for your experimentation. The commands you are
looking at are executed by everyone in this multi-user environment.
There are no protections - when you change it everyone gets the net
effect immediately. This is why we like the environment. In your own
account you can do just about whatever you want with impunity. You
may also want to consider training, getting closer to your VAR or
another mentor, and looking up resources of MV documentation. The D3
Reference Manual v7.5 is probably the best D3 reference available.
It's not perfect but probably good enough for now.

HTML:
<http://www.rainingdata.com/support/documentation/d3nt/75/refman/index.htm>
PDF:
<ftp://ftp.rainingdata.com/pub/NT/7.5.0/Documentation/>


HTH. Don't hesitate to ask more questions,
the bark around here is much worse than the bite...

Tony Gravagno
Nebula Research and Development


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.