[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Aug 12 21:11:25 1994 
Subject:Re: rc_print_at 
From:Adrian John Howard 
Volume-ID:940813.03 

> To draw an axis with a scale in a window, I have used the command rc_print_at
> as below. This command has to be repeated for different values on the scale, ie.
> 0, 100, 200 etc., since the third arguement of rc_print_at has to be a string.
> Is there a `better' way of doing this, so as to accomodate for changes in the
> scale? Is there a command that prints out a value of a variable instead of
> printint a string?

Easy. Just turn the variable into a string! Take a look at the two
operators >< and sys_>< in REF * PRINT. They produce a string which is
the concatenation of the objects printed representation. For example:

    vars s = 12 >< "hello";
    s.isstring=>
    ** <true>
    s=>
    ** 12hello

The difference between sys_>< and >< is that sys_>< sets uses the system
printing procedure -sys_syspr- (rather than the -class_print- of the
object) and sets all the "pop_pr_" variables to there default values.
An example of the difference would be;

    ;;; Causes quotes to be printed around strings...
    true -> pop_pr_quotes;

    ;;; like this...
    'a string'=>
    ** 'a string'

    ;;; Build strings with >< and sys_><
    vars s1 = 'the integer one is ' >< 1;
    vars s2 = 'the integer one is ' sys_>< 1;

    ;;; Stop printing quotes
    false -> pop_pr_quotes;

    ;;; -s1- has extra quotes since it uses the default printing proc
    s1=>
    ** 'the integer one is '1

    ;;; -s2- doesn't since sys_>< locally resets pop_pr_quotes
    s2=>
    ** the integer one is 1

So, you would want something like this to draw your axis labels.

    rc_drawline(-450,0,450,0);
    lvars c;
    for c from -450 by 100 to 450 do
        rc_drawline(c,0,c,-5);
        rc_print_at(c, -17, c+450 sys_>< nullstring);
    endfor;

You might find -sprintf- of interest too.

Adrian

aids (adrianh@cogs.susx.ac.uk)  ObDisclamer: Poplog used to pay my wages
Phone: +44 (0)273 678367  URL: http://www.cogs.susx.ac.uk/users/adrianh/

PS If you're drawing graphs, take a look at TEACH * RC_GRAPHPLOT. It
will make your life a whole lot easier :-)