cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying info on the status bar

Highlighted

Displaying info on the status bar

Sorry, I accidentally hit the "Send" shortcut key...

What I meant to say was, I've set the WHILE rule to:

while (($numvalue == 0) && ($object != oid_first()))

to prevent the function locking at the top of the file, and I'm using

$object = oid_backward($object)

to go to the previous element. But still no joy.

Any ideas?

Matt

Displaying info on the status bar

For those who are interested, I got it to work!
Here's the successful code...

# Get_number function, written by Matt Clifton
# 8 July 1999
#
# Will find the previous "page" tag from the caret location
# and report its "number" attribute value to the status bar.
# It refreshes every 2 seconds.

# get_number tracks up the elements and finds the last "page" tag.
# It returns the value of the "number" attribute.

function get_number()
{

# $object is the variable used to hold the OID we're looking at

$object = (oid_caret()) ;

# $newobj is set up to be identical to $object; it later holds the previous
element.

$newobj = $object ;

# $objectname holds the name of the element referred to by $object

$objectname = base_tag_name(oid_name($object)) ;

# Go into this loop if the current object is not "page", and we're not at
the top of the file

while ((oid_backward($newobj) != oid_null()) && ($objectname != "page"))
{

# Go one object backwards and get the new element name

$newobj = oid_backward($object)
$object = $newobj
$objectname = base_tag_name(oid_name($object)) ;
}

# We're out of the loop (ie at filestart, or succeeded in finding a page)
# Set $numvalue to the value of the "number" attribute
# (it will be null if we're at the top of the file)

$numvalue = oid_attr($object, 'number') ;
return $numvalue;
}

# update_page runs the get_number function and puts the result to the status
bar

function update_page()
{
$numvalue = get_number();
message "Page number $numvalue" ;
return 1;
}

# and here's my callback to run the update_page function every 2 seconds

timer_add_callback(200, 'update_page', doc_window())

Displaying info on the status bar

Dear Adepters -

We hold page tags in our SGML data. I'd like to display the value of the
"number" attribute of the current page element on the Adept Editor status
bar, and have it continually updated, in the same way that the element
hierarchy is displayed. This way, the user can see at a glance which page
they're looking at, without having to do a search for the previous page
element.

Is this possible using ACL?

Thanks

Matt Clifton

Displaying info on the status bar

Thanks Svante.

I can see how this calls a function on each shift in caret position, but
what I really need is that function - to locate the value of an attribute
and put it to the status bar (or a separate window, I don't mind which).

If there isn't a simple solution to this, don't worry - it was just a
nice-to-have feature that our editors would find useful.

Matt

Displaying info on the status bar

Matt,

There is an undocumented callback "caretMovedCallback" which you may want
to use.

See $ADEPTHOME/packages/tools/_toptags.cmd and .../html/_www.cmd for
example code.

As always, undocumented stuff is (usually) undocumented for a reason,
so think twice before using this approach in production grade code.

/ Svante Kleist - NEMESIS systemDesign, Stockholm, Sweden

Displaying info on the status bar

message "$attribute_value"

will display the attribute value at the lower left status line of the
pane (of course, you have to initialize the variable $attribute_value
to it; for that you'd probably want to use oid_attr(oid_caret(),
attr_name) ) or some variation thereof -- more info available through
"help oid") . If the window is too narrow to accomodate the value, it
will display a dismissable message window.

Eduardo

Displaying info on the status bar

OK, I've followed the advice of Svante, Eduardo and Peter, and come up with
the following:
(It's my first piece of ACL code, so please don't laugh...).

The timer works, the message display works...and the attribute locating
function fails dismally. All that comes up is "Page: ".

I tried using both oid_parent and oid_prev to get the previous element, and
neither returned a success.

The page element is the only element with a "number" attribute, and it's an
inclusion (ie allowed everywhere) if that makes a difference.

I can't help feeling it's something to do with the oid_has_attr function,
which I'm not sure I'm invoking properly.

Can anyone see what I'm doing wrong?

Matt

--

# Code to find the previous "page" element and put the value of the "number"
attribute to the screen

global nticks=0

# get_number tracks up the elements and finds one with a "number" attribute,
# returning the value of "number"

function get_number()
{
$numvalue=0
$object=oid_current_tag()

while ($numvalue=0)
{
$test_oid = oid_has_attr($object, 'number')
if ($test_oid = 1)
{
$numvalue=oid_attr($object, 'number')
return $numvalue
}
$object=oid_prev($object)

}
}

# display_page_no runs the get_number function
# and puts the result to the status bar

function display_page_no()
{
$num=get_number()
message "Page: $num"
}

# update_page runs the get_number function

function update_page()
{
display_page_no()
return 1;
}

# and here's my callback to run the update_page function every 5 seconds

timer_add_callback(500, 'update_page', doc_window())

# end of code.

Displaying info on the status bar

Matt,

Certainly no laughs from me, since I've done the same
blunder as you many, many times...

if ($test_oid = 1)

This always evaluates to true, should be

if ($test_oid == 1)

Now a days, I have the habit to write

if ( 1 == test_oid )

the "reversed" order ensures that I don't make the mistake,
since that would be a syntax error.

/ Svante Kleist - NEMESIS systemDesign, Stockholm, Sweden

Displaying info on the status bar

Sorry, I accidentally hit the "Send" shortcut key...

What I meant to say was, I've set the WHILE rule to:

while (($numvalue == 0) && ($object != oid_first()))

to prevent the function locking at the top of the file, and I'm using

$object = oid_backward($object)

to go to the previous element. But still no joy.

Any ideas?

Matt