Home > database > set_form_col_const.m

set_form_col_const

PURPOSE ^

Figures out which data columns correspond to different database fields in the form table.

SYNOPSIS ^

function FD = set_form_col_const(var_list);

DESCRIPTION ^

 Figures out which data columns correspond to different database fields in the form table.

 Use of the FD structure when indexing into form data ensures portability of code
 in the event that the field ordering in the database changes or if only a subset
 of fields are retrieved in a query.

 var_list is a cell string containing field names
 FD is a structure with constants (column ids) assigned for the following
 fields:

 SUB_ID -- subject ID
 STIM_ID -- stimulus ID
 DATE_TIME -- datestamp
 QUEST_ID -- question ID
 QUEST_TXT -- question text
 SUBQUEST_TXT -- subquestion text (heading)
 SUBQUEST_ID -- subquestion ID
 QUEST_ITER -- question iteration
 RESP_ENUM -- response value
 RESP_TXT -- response text
 RESP_ID -- incrementing response ID counter
 SESS_ID -- session ID
 FORM_ID -- form ID

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function FD = set_form_col_const(var_list);
0002 % Figures out which data columns correspond to different database fields in the form table.
0003 %
0004 % Use of the FD structure when indexing into form data ensures portability of code
0005 % in the event that the field ordering in the database changes or if only a subset
0006 % of fields are retrieved in a query.
0007 %
0008 % var_list is a cell string containing field names
0009 % FD is a structure with constants (column ids) assigned for the following
0010 % fields:
0011 %
0012 % SUB_ID -- subject ID
0013 % STIM_ID -- stimulus ID
0014 % DATE_TIME -- datestamp
0015 % QUEST_ID -- question ID
0016 % QUEST_TXT -- question text
0017 % SUBQUEST_TXT -- subquestion text (heading)
0018 % SUBQUEST_ID -- subquestion ID
0019 % QUEST_ITER -- question iteration
0020 % RESP_ENUM -- response value
0021 % RESP_TXT -- response text
0022 % RESP_ID -- incrementing response ID counter
0023 % SESS_ID -- session ID
0024 % FORM_ID -- form ID
0025 %
0026 
0027 % March 2005, Petr Janata
0028 % 06/22/06 PJ - added session_id handling
0029 % 01/04/07 PJ - added form_id handling
0030 
0031 nvars = length(var_list);
0032 
0033 FD = struct('SUB_ID',[], ...
0034     'STIM_ID',[], ...
0035     'DATE_TIME',[], ...
0036     'QUEST_ID',[], ...
0037     'QUEST_TXT',[], ...
0038     'SUBQUEST_TXT',[], ...
0039     'SUBQUEST_ID',[], ...
0040     'QUEST_ITER',[], ...
0041     'RESP_ENUM',[], ...
0042     'RESP_TXT',[], ...
0043     'RESP_ID',[], ...
0044     'SESS_ID',[], ...
0045     'FORM_ID',[] ...
0046     );
0047 
0048 for ivar = 1:nvars
0049   switch var_list{ivar}
0050     case 'subject_id'
0051       FD.SUB_ID = ivar;
0052       
0053     case 'stimulus_id'
0054       FD.STIM_ID = ivar;
0055       
0056     case 'date_time'
0057       FD.DATE_TIME = ivar;
0058       
0059     case 'question_id'
0060       FD.QUEST_ID = ivar;
0061       
0062     case 'subquestion'
0063       FD.SUBQUEST_ID = ivar;
0064 
0065     case 'question_iteration'
0066       FD.QUEST_ITER = ivar;
0067     
0068     case 'response_enum'
0069       FD.RESP_ENUM = ivar;
0070     
0071     case 'response_text'
0072       FD.RESP_TXT = ivar;
0073     
0074     case 'question_text'
0075       FD.QUEST_TXT = ivar;
0076     
0077     case 'heading'
0078       FD.SUBQUEST_TXT = ivar;
0079       
0080     case 'response_id'
0081       FD.RESP_ID = ivar;
0082   
0083     case 'session_id'
0084       FD.SESS_ID = ivar;
0085     
0086     case 'form_id'
0087       FD.FORM_ID = ivar;
0088   end % switch
0089 end % for ivar
0090 
0091 return

Generated on Sun 24-Mar-2019 04:00:51 by m2html © 2003