• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
        • Audio Statement
        • Audio.load Function
        • Audio.save Function
        • Audio.play Function
        • Audio.recordInteractive Function
        • Audio.record Function
        • Audio.stop Function
        • Audio.concat Function
        • Audio.length Function
        • Audio.clear Function
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Audio.clear Function

Format
b = audio_name.clear();
Description
The Audio.clear function removes the current recording from an Audio object making it empty.
Return Value
The function returns a logical value of 1 (true) on success, or 0 (false) if called on an occurrence of a binary dictionary item that does not exist.
Example
PROC AUDIO_QUESTION

onfocus

   
// Variable to store the recording
    Audio recording;

   
// Save recording to a file that includes case id-items to differentiate it from
    // audio saved in other cases
    string nameOfAudioFile = maketext("%v%v%vAUDIO_QUESTION.m4a", PROVINCE, DISTRICT, EA);

   
// If no audio is recorded for this question then the only option is to record,
    // otherwise allow user to re-record, play or clear recording before continuing
    ValueSet vs;
   
if fileexist(nameOfAudioFile) and recording.load(nameOfAudioFile) then
        vs.
add("Re-record", 1);
        vs.
add("Play recording", 2);
        vs.
add("Clear recording", 3);
        vs.
add("Next question", 4);
   
else
        vs.
add("Record", 1);
   
endif;

   
setvalueset($, vs);

postproc

   
if $ = 1 then
       
// Record/re-record
        recording.clear();
       
string message = "Record the respondent's answer to this question";
       
numeric seconds = recording.recordInteractive(message);
       
if seconds > 0 then
            recording.
save(nameOfAudioFile);
       
else
           
errmsg("No audio recorded. Please try again");
       
endif;
       
reenter;
   
elseif $ = 2 then
       
// Play back recording
        recording.play();
       
reenter;
   
elseif $ = 3 then
       
// Clear the recording
        filedelete(nameOfAudioFile);
       
reenter;
   
elseif $ = 4 then
       
// Continue to next question
    endif;
See also: Audio Object