/*
** $VER: getattr.ped 1.0 (30.8.94) written by Robert Brandner
**
** Demo of the usage of the GETATTR command
*/

/* enable return codes */
               
OPTIONS RESULTS

/* is PolyEd out there ? */

if ~SHOW("Ports", "POLYED.1") then do
	say "Please start PolyEd before running this program."
	exit
end

ADDRESS POLYED.1

/* First, how to get all informations on the application:
** The informations are placed in nodes of the stem variable APP. 
** If we don't use a stem variable all informations are put into
** the variable RESULT, seperated by spaces.
*/

'GETATTR APPLICATION STEM APP.'

say "Informations about PolyEd"
say "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ"
say "Version        :" APP.VERSION
say "Pub Screen     :" APP.SCREEN
say "Current Project:" APP.CURRENT
say "Findstring     :" APP.VAR_FINDSTRING
say "Changestring   :" APP.VAR_CHANGESTRING
say "Learning       :" APP.FLAG_LEARNING
say "Right Border   :" APP.VAR_RIGHTBORDER
say "Overwrite      :" APP.FLAG_OVERWRITE
say
say "and so on..."

say "You may now ask for information of specific fields."
say "See documentation for the available fields."
say "Enter no field name for leaving the loop."
say ""


OPTIONS prompt "application field:"

pull field
do while field ~= ""
    'GETATTR APPLICATION FIELD' field
	say field || ":" RESULT
	say ""
	pull field
end

/* Now we get a list of all projects */

OPTIONS PROMPT

say
say "Press <return> for a list of the projects:"
pull
say

'GETATTR PROJECTS STEM P.'
say "Here is a list of the" P.PROJECTS.COUNT "projects of PolyEd:"
say
do i=0 to P.PROJECTS.COUNT-1	/* from 0 to COUNT-1 ! */
	say "["i+1"]" P.PROJECTS.i

	/* Here we get the informations on one project
	** into the stem variable PR. Variables must not be quoted, because
	** ARexx does not evalute them if they are.
	*/

	'GETATTR' PROJECT P.PROJECTS.i STEM PR.
	say substr("", 1, 3+length(i)+length(P.PROJECTS.i), "Ż")	/* :^) */
	say 'ARexx port        :' PR.AREXX
	say 'complete filename :' PR.FILENAME
	say 'file portion      :' PR.FILE
	say 'path portion      :' PR.PATH
	say 'modifications     :' PR.CHANGES
	say 'lines             :' PR.LINES
	say
end i

/* Now a list of the macros */

say
say "Press <return> for a list of the macros:"
pull
say

'GETATTR MACROS STEM M.'

say "Here is a list of the" M.MACROS.COUNT "macros of PolyEd:"
say
do i=0 to M.MACROS.COUNT-1
	say M.MACROS.i
end i
