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 >
Text File  |  2010-09-21  |  2KB  |  54 lines

  1. <<
  2.     // define the database name for convenience
  3.     kSurveyDB = "my_survey";
  4.  
  5.     // Make sure the database exists. vGetDatabases is a
  6.     // built-in function that (appropriately) returns a 
  7.     // list of available Verona databases, so we just use
  8.     // the "in" keyword to see if our database is 
  9.     // available.
  10.  
  11.     database_list = vGetDatabases ();    
  12.  
  13.     if not (kSurveyDB in database_list)
  14.         // didn't find it, so create the database
  15.         vMakeDatabase (kSurveyDB);
  16.         // the second parameter to vAddField is a list
  17.         // specifying the field's unique 4-character ID,
  18.         // name, type, and size (if the type is "text").
  19.         vAddField (kSurveyDB, ["ipad" "IP Address" "text" 16]);
  20.         vAddField (kSurveyDB, ["qst1" "Q1 Answer" "text" 1]);
  21.         vAddField (kSurveyDB, ["qst2" "Q2 Answer" "text" 3]);
  22.     end if;
  23.  
  24.     matching_records = vCountMatching (kSurveyDB, "ipad", "=",
  25.                                                                     client_ip_address);
  26.     if (matching_records = 0)
  27.         vAddRecord (kSurveyDB, [
  28.                                                     ["ipad" client_ip_address]
  29.                                                     ["qst1" yesno]
  30.                                                     ["qst2" Vowel]
  31.                                                     ]);
  32.     end if;
  33.  
  34.     total_answers = vCountRecords (kSurveyDB);
  35.  
  36.     q1_yes = vCountMatching (kSurveyDB, "qst1", "=", "Yes");
  37.     q1_no = total_answers - q1_yes;
  38.  
  39.     q2_a = vCountMatching (kSurveyDB, "qst2", "=", "A");
  40.     q2_e = vCountMatching (kSurveyDB, "qst2", "=", "E");
  41.     q2_i = vCountMatching (kSurveyDB, "qst2", "=", "I");
  42.     q2_o = vCountMatching (kSurveyDB, "qst2", "=", "O");
  43.     q2_u = vCountMatching (kSurveyDB, "qst2", "=", "U");
  44.  
  45.     q1_yes_pcnt = (q1_yes / total_answers * 100) as integer;
  46.     q1_no_pcnt =  (q1_no  / total_answers * 100) as integer;
  47.  
  48.     q2_a_pcnt =   (q2_a   / total_answers * 100) as integer;
  49.     q2_e_pcnt =   (q2_e   / total_answers * 100) as integer;
  50.     q2_i_pcnt =   (q2_i   / total_answers * 100) as integer;
  51.     q2_o_pcnt =   (q2_o   / total_answers * 100) as integer;
  52.     q2_u_pcnt =   (q2_u   / total_answers * 100) as integer;
  53.  
  54.