home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
netprofessional
/
code
/
02.02
/
SiphonForms.answer.html(v3).txt
< prev
next >
Wrap
Text File
|
2010-09-21
|
2KB
|
54 lines
<<
// define the database name for convenience
kSurveyDB = "my_survey";
// Make sure the database exists. vGetDatabases is a
// built-in function that (appropriately) returns a
// list of available Verona databases, so we just use
// the "in" keyword to see if our database is
// available.
database_list = vGetDatabases ();
if not (kSurveyDB in database_list)
// didn't find it, so create the database
vMakeDatabase (kSurveyDB);
// the second parameter to vAddField is a list
// specifying the field's unique 4-character ID,
// name, type, and size (if the type is "text").
vAddField (kSurveyDB, ["ipad" "IP Address" "text" 16]);
vAddField (kSurveyDB, ["qst1" "Q1 Answer" "text" 1]);
vAddField (kSurveyDB, ["qst2" "Q2 Answer" "text" 3]);
end if;
matching_records = vCountMatching (kSurveyDB, "ipad", "=",
client_ip_address);
if (matching_records = 0)
vAddRecord (kSurveyDB, [
["ipad" client_ip_address]
["qst1" yesno]
["qst2" Vowel]
]);
end if;
total_answers = vCountRecords (kSurveyDB);
q1_yes = vCountMatching (kSurveyDB, "qst1", "=", "Yes");
q1_no = total_answers - q1_yes;
q2_a = vCountMatching (kSurveyDB, "qst2", "=", "A");
q2_e = vCountMatching (kSurveyDB, "qst2", "=", "E");
q2_i = vCountMatching (kSurveyDB, "qst2", "=", "I");
q2_o = vCountMatching (kSurveyDB, "qst2", "=", "O");
q2_u = vCountMatching (kSurveyDB, "qst2", "=", "U");
q1_yes_pcnt = (q1_yes / total_answers * 100) as integer;
q1_no_pcnt = (q1_no / total_answers * 100) as integer;
q2_a_pcnt = (q2_a / total_answers * 100) as integer;
q2_e_pcnt = (q2_e / total_answers * 100) as integer;
q2_i_pcnt = (q2_i / total_answers * 100) as integer;
q2_o_pcnt = (q2_o / total_answers * 100) as integer;
q2_u_pcnt = (q2_u / total_answers * 100) as integer;