HTML Listing Report

Discussions about editing and cleaning data
Post Reply
Gregory Martin
Posts: 1793
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

HTML Listing Report

Post by Gregory Martin »

At the moment, CSPro's listing files (.lst) are only text files. There are a few custom parameters to the file located in the .pff file:

ListingWidth=80
MessageWrap=No
ErrmsgOverride=No

But for more control over how users see listing reports after a program run, a programmer may want to output listing results in a different format.

Attached is a very simple program of a batch program that outputs an HTML file and then opens the file with Internet Explorer after the program run. This code could be made more robust by putting the HTML output statements in functions, like: beginParagraph, endParagraph, writeMessage, etc. Thought the program is very basic, it shows how, with external file write operations, a programmer can design more sophisticated listing reports.
PROC GLOBAL

file html;

PROC CREATEHTML_FF

preproc

    
filewrite(html,"<html><head><title>CSPro Output</title>");

postproc

    
filewrite(html,"</html>");

    
close(html);

    
execsystem(maketext('%s\Internet Explorer\iexplore.exe "%s"',pathname(ProgramFiles64),filename(html)));


PROC CREATEHTML_QUEST

preproc

    
filewrite(html,"<p><strong>Questionnaire %d</strong><br />",CREATEHTML_ID);

postproc

    
filewrite(html,"</p>");

PROC VALUE

    
filewrite(html,"Value is %d<br />",VALUE);
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: HTML Listing Report

Post by lls »

I'm very interested to learn how to export a questionnaire in HTML format, but I did not fully understand this code (being a very beginner)

I tried to create a batch programm and I changed some of the information according to my CSPro applicationbut, but the code has generated the error message (see below), as if a parenthesis was missing:

------------
ERROR: Expecting right parenthesis ')'in a function call near line 12 in GDC_DOSSIERS_FF procedure
------------


{Application 'BATCHHTML' logic file generated by CSPro }
PROC GLOBAL

file html;

PROC GDC_DOSSIERS_FF

preproc

filewrite(html,"CSPro Output");

postproc

filewrite(html,"");

close(html);

execsystem(maketext('%s\Internet Explorer\iexplore.exe "%s"',pathname(ProgramFiles64),filename(html)));

PROC GDC_DOSSIERS

preproc

filewrite(html,"Questionnaire %d",GDC_QUESTIONNAIRE_ID);

postproc

filewrite(html,"");

PROC Q22_STATETAT

filewrite(html,"Value is %d",Q22_STATETAT);
Gregory Martin
Posts: 1793
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: HTML Listing Report

Post by Gregory Martin »

I think the problem is that you're using a version of CSPro without the ProgramFiles64 declaration. Download the most recent beta here:

http://www.csprousers.org/testers
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: HTML Listing Report

Post by lls »

Thank you very much. It is working fine.

For anyone who might be interested, here are two codes as example.

The first one will generate the corresponding value: (male/female)
The second will generate numbers: (age)

PROC Q12_SEXE

filewrite(html,"Sexe: %s", getlabel ($,$));

PROC Q13_AGE

filewrite(html,"Age: %d",$);
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: HTML Listing Report

Post by lls »

I would like to automize some function, including the HTML report.

The Batch application works fine if open from itself. If I try to automize the launch with the code below, it will launch correctly, but it will not find the HTML file (which is already created)
For example:

...
elseif $ = 4 then

execpff("c:..\\Batch\\BatchHTML.pff");
reenter;
...

This will generate an error message:

Cannot find 'file:///c:../Questionnaires.html'. Make sure the path or Internet address is correct

How can I specify the path to the HTML file?
Post Reply