Yes, You Can Make Your Own Report Writer!

Have you wanted to give your users the power to write their own reports, have complete control over the code, and at a low cost? Really hard, right? Uh-Uh.

One of the most important elements of a report writer is the mail merge routine. My basic mail merge routine is a process of

1)Finding a token
2)Saving the part of the string after the token
3)Isolating the token, by blanking the right of the token
4)Replacing the token with data.
5) Adding the saved data

The routine looks like this:

MERGER ROUTINE !MailMerge Engine
  LOOP LEN(CLIP(rtext)) TIMES
 !Find the token
     cc=INSTRING(CLIP(mer:mergevar),UPPER(CLIP(rtext)),1,1)
     IF cc>0
        dd=cc
!save everything to the right of the token
      tempspace=rtext[(cc+LEN(CLIP(MER:mergevar))) : LEN(rtext)]
!now blank everything to the right
        rtext[(cc+LEN(CLIP(MER:mergevar))) : LEN(rtext)]=''
 !Now do merge
        rtext[cc : cc+LEN(mergedata)]=CLIP(mergedata)
 !Now put data back together
        rtext=CLIP(rtext)&CLIP(tempspace)
     END!IF
  END!IF

You will need to write a routine to search your string (sentence, paragraph, etc) for tokens
Usually this is in an accept embed of the Merge button.
After your routine finds the token , it calls the merger routine above. It will merge the corresponding database field field with the token. The process repeats for each token the app finds.

The example contains the use of  this routine. I have not spent much time cleaning up the example, but just enough to demonstrate the routine. So, please feel free to fix up the code as you like.

Download Example (rwrite.zip 11Kbytes)

Take a look and send me comments and questions.
 

Mike Pasley
Team Topspeed - Internet Connect
 
 
 

Questions? Comments?
Email MikePasley at mpasley@logicentral.com
 
 

An mp.jpgSite Development - Copyright 1998