RPV Reports / Usage Examples
 
Search in RpvSoftware.com
Go!                                         English    Español

What Rpv is

Rpv Reports 2024

Downloads

Training/Consultancy

Support

Purchase

Contact

 
Home > Usage Examples
Awk #1
This example shows how to prepare a report using AWK programming language & RPV Reports.

This program reads the person.dat file (see samples) that must be stored on a Unix system.

This example turns in red all those monthly salaries below 1400; that is the reason of the if.
We have used print & printf commands. We took advantage of the printf command because it doesn't insert a newline.

How to run this
1- Save this code and name it with anyname.awk.

2- Place the file person.dat in the computer for the program to be able to read it.

3- Execute this at the prompt:
# awk -f anyname.awk person.dat > listing.rpv ; mv listing.rpv /tmp/rpvqueue

Important aditional information
- Please observe that the awk program has a pic inside pointing "c:\program files\rpv\samples" (the rpv logo). What this means is that the logo is stored in the computer which runs the Rpv server.

- You could want to print a bitmap that you have stored in the unix machine. To do so, just reference without the path, and be sure to copy it to the queue directory BEFORE you place the Rpv file there.
Code
BEGIN {

    FS = "," ;
    print "report_title=Employees report Example with Awk";
    print "orientation=2";
    print "open_view";
    print "spacing=250";
    print "$c0=400";
    print "$c1=1000";
    print "$c2=3400";
    print "$c3=6800";
    print "$c4=8400";
    print "$c5=11000";
    print "$c6=13000";
    print "$c7=13200";
    print "[header]";
    print "{f=arial;s=8}";
    print "{pic=c:program filesrpvsamplesrpvlogo.bmp,400,400,1400,900}";
    print "{n;$c7} Page {12800;pag}";
    print "{s=16;n;1800;c=2;b=y} Sample Application Report {spacing=350;n}";
    printf "{c=1;1800} Employees Report (one line per record).n"
    printf {c=0;b=n;n;n;n}n";
    print "{LINE=400,14000;n}";
    printf "{s=8;b=y;$c0} ID {$c1} Name {$c2} Address {$c3} Phone {$c4} E-mail" printf "{$c5} Birth date {a=r;$c6} Mon Salary {a=l;$c7} Schedule"
    printf "{b=n;spacing=375;n}n";
    print "{LINE=400,14000;n}"
    print "[data]"}

    {

        printf "{$c0}" $1
        printf "{$c1}" $2
        printf "{$c2}" $3
        printf "{$c3}" $4
        printf "{$c4}" $6
        printf "{$c5}" $7
        printf "{a=r;"

        { if($8 < 1400)

            {
            printf "c=12;"
            }

        }

    printf "$c6}" $8 "{c=0;a=l;$c7}" $10 "{n}n"

    }

Home
What Rpv is
Rpv Reports 2024

Products
Rpv Reports 2024
Personalized edition

More...
Downloads
Support
Rpv Reports Online help
Rpv Visual Editor online help
Examples
/temp section
Videos




Copyright (c) 2001-2024 - Rpv Software. All rights reserved.