A Background Painter

Introduction

Suppose you were writing some graphical software written in sas code that you intended to sell. You maybe want people to be able to use it for a while for free without being put under any pressure to buy it.  But on the other hand, you don't want them to carry on using it for a long time without them paying you for it. Well, if it's a graphical application you are writing using annotate datasets then how about painting the background with your name or email address. So long as you have not supplied the source code, you can fix it so that your message becomes clearer with time to the point where it becomes so noticeable that they will either give up using it or pay you. Note that you can only make your code secure from sas version 9.2 onwards and only if you compile your macro code with the "/ store secure" options and write it to a catalog.

Annotate code for painting backgrounds

I have some code in the form of a macro that you can play around with. If you were serious about painting the background then you would want to do it as a routine, rather than call a macro, since you would want the annotate instructions to be part of the same annotate dataset that you were creating for your application. But it is below for you to play with. I set vpos=25 and hpos=40 in a goptions statement before running this code and calling "proc ganno". I use these same values as parameters to the macro. Feel free to run the code and note how much clearer the background text becomes the longer ago it was to "startdate".
 
goptions reset=all cback=FloralWhite vpos=25 hpos=40;

%macro bgpainter(hpos=,vpos=,text=,height=,font=,angle=,across=,down=,startdate=);

data _bgpainter(keep=x y function text angle size style position xsys ysys hsys color when);
  length style $ 32;
  retain xsys ysys hsys '4' text &text style "&font" position "+" when "B";
  retain holdy holdx xinc ydec daysago ctot 0 angle &angle size &height;
  length color cstring $ 8 function $ 8;
  array _ctemp {6} $ 8 _temporary_ ("CXFFFFE0" "CXFFFEFF" "CXD0FFFF" "CXFFFEFE" "CXE0FFE0" "CXFEFEFF") ;
  if _n_=1 then do;
    daysago=date()-&startdate;
    ydec= &vpos / &down;
    xinc= &hpos / &across;
    holdy= &vpos + ydec/2;
    ctot=dim(_ctemp);
  end;
  cnum=0;
  do i=1 to &down;
    holdy=holdy-ydec;
    holdx=0-xinc/2;
    do j=1 to &across;
      holdx=holdx+xinc;
      cnum=cnum+1;
      cstring=_ctemp(mod(cnum-1,ctot)+1);
      do k=3,5,7;
        if substr(cstring,k,2) NE "FF" then do;
          num=input(substr(cstring,k,2),hex2.);
          num=round(num-daysago/5);
          if num<0 then num=0;
          substr(cstring,k,2)=put(num,hex2.);
        end;
      end;
      color=cstring;
      x=holdx;
      y=holdy;
      function="move";
      output;
      function="label";
      output;
    end;
  end;
run;

%mend bgpainter;

%bgpainter(across=4,down=5,text="rolandberry@hotmail.com",angle=30,height=1,font='Arial',
vpos=25,hpos=40,startdate="26dec07"d);

proc print data=_bgpainter;
run;

proc ganno annotate=_bgpainter;
run;
 

Conclusion

You have seen how you could use an annotate dataset to write to the background of a graphical application you are writing whose intensity increases with time.


 
 

Go back to the home page.

E-mail the macro and web site author.