<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>> Bart <bartjunk64@gmail.com> wrote:<br/></div><div>> Please provide code example.</div><div><br/></div><div>program Probabilistic;<br/><br/>uses Classes, System;<br/><br/>const Students = 415; { no of students }<br/> Questions = 517; { no of questions }<br/> TAB = #9; { <TAB> character }<br/><br/>type SexType = (male, female);<br/> ExamType = (Nano1, Nano2, Mini2, Mini3, Final);<br/> ResultType = (pass, fail, miss);<br/> AdmissionR = record<br/> MCAT, MCBS, MCPS, MCVR : byte;<br/> MCWS : char;<br/> OGPA, PGPA, Levl : double;<br/> Sex : SexType;<br/> end;<br/> ExamR = record<br/> Total : word;<br/> Percent, time : double;<br/> Result : ResultType;<br/> end;<br/> QuestionR = record<br/> Letter : char;<br/> Score : byte;<br/> end;<br/> AdmissionField = array[1..Students] of AdmissionR; { Admission data }<br/> ExamField = array[ExamType, 1..Students] of ExamR; { overall exam results }<br/> QuestionField = array[1..Questions, 1..Students] of QuestionR; { question by question results }<br/><br/>var AdmissionData : AdmissionField;<br/> ExamData : ExamField;<br/> QuestionData : QuestionField;<br/><br/>procedure ReadDataFile;<br/>{ read the data matrix from a <TAB>-separated text file (as produced by Excel) }<br/><br/>const FileName : string = 'Sem1-Responses.txt';<br/><br/>var StudentNo, QuestionNo : word;<br/> DataFile : text;<br/> Hilfs : char;<br/> Exam : ExamType;<br/><br/> function ReadByte : byte;<br/><br/> var hilfs : char;<br/> hst : string;<br/> value : byte;<br/> error : integer;<br/><br/> begin<br/> hst := '';<br/> read(DataFile, hilfs);<br/> while (hilfs <> TAB) do<br/> begin<br/> if (hilfs = '-')<br/> then<br/> ReadByte := 255; { used as 'data not available' marker }<br/> exit;<br/> end;<br/> hst := hst + hilfs;<br/> read(DataFile, hilfs);<br/> end;<br/> Val(hilfs, value, error);<br/> if error <> 0<br/> then<br/> begin<br/> writeln('Error: Byte string ', hst, 'in line ', StudentNo:3);<br/> halt;<br/> end<br/> else<br/> ReadByte := value;<br/> end; { ReadByte }<br/><br/> function ReadChar : char;<br/><br/> var hilfs : char;<br/><br/> begin<br/> read(DataFile, hilfs);<br/> ReadChar := value;<br/> read(DataFile, hilfs); { remove <TAB> before next value }<br/> end; { ReadChar }<br/><br/> function ReadFloat : double;<br/><br/> var hilfs : char;<br/> hst : string;<br/> value : double;<br/> error : integer;<br/><br/> begin<br/> hst := '';<br/> read(DataFile, hilfs);<br/> while (hilfs <> TAB) do<br/> begin<br/> if (hilfs = '-')<br/> then<br/> ReadFloat := NAN; { used as 'data not available' marker }<br/> exit;<br/> end;<br/> hst := hst + hilfs;<br/> read(DataFile, hilfs);<br/> end;<br/> Val(hilfs, value, error);<br/> if error <> 0<br/> then<br/> begin<br/> writeln('Error: Float string ', hst, 'in line ', StudentNo:3);<br/> halt;<br/> end<br/> else<br/> ReadFloat := value;<br/> end; { ReadFloat }<br/><br/> Procedure ReadSex (var Sex : SexType);<br/><br/> var hilfs : char;<br/><br/> begin<br/> read(DataFile, hilfs):<br/> Case hilfs of<br/> "M" : Sex = male;<br/> "F" : Sex = female;<br/> else : begin<br/> writeln('Error: character for student sex = ', hilfs:1, ' in line ', StudentNo:3);<br/> halt;<br/> end;<br/> end { case }<br/> read(DataFile, hilfs); { remove <TAB> before next value }<br/> end; { ReadSex }<br/><br/> function ReadTime : double;<br/> { converts a hh:mm:ss string into minutes with decimal (for seconds) }<br/><br/> var TimeStr : string[8];<br/> hst : string[2]<br/> hilfs : char;<br/> value1,<br/> value2 : double;<br/> error : integer;<br/><br/> begin<br/> Read(DataFile, TimeStr);<br/> if TimeStr[1] = '-' { missing data }<br/> then<br/> begin<br/> ReadTime := NAN;<br/> exit;<br/> end;<br/> hst[1] := TimeStr[1];<br/> hst[2] := TimeStr[2]; { hours }<br/> Val(hast, value1, error);<br/> if (error <> 0)<br/> then<br/> begin<br/> writeln('Error: time str = ', TimeStr, ' in line ', StudentNo:3);<br/> halt;<br/> end;<br/> hst[1] := TimeStr[4]; { minutes }<br/> hst[2] := TimeStr[5];<br/> Val(hast, value2, error);<br/> if (error <> 0)<br/> then<br/> begin<br/> writeln('Error: time str = ', TimeStr, ' in line ', StudentNo:3);<br/> halt;<br/> end;<br/> Value1 := Value1*60 + Value2;<br/> hst[1] := TimeStr[7]; { seconds }<br/> hst[2] := TimeStr[8];<br/> Val(hast, value2, error);<br/> if (error <> 0)<br/> then<br/> begin<br/> writeln('Error: time str = ', TimeStr, ' in line ', StudentNo:3);<br/> halt;<br/> end;<br/> Value1 := value1 + Value2/60;<br/> read(DataFile, hilfs); { remove <TAB> before next value }<br/> ReadTime := Value1;<br/> end;<br/><br/> procedure ReadPassFail (Result : ResultT);<br/> { read pass, fail and missing from the data file }<br/><br/> var ResultStr : string[4];<br/> hilfs : char;<br/><br/> begin<br/> read(DataFile, ResultStr);<br/> case ResultStr of<br/> 'Pass' : Result = pass;<br/> 'Fail' : Result = fail;<br/> '- ' : Result = miss;<br/> else begin<br/> writeln('Error: Result str = ', ResultStr, ' in line ', StudentNo:3);<br/> halt;<br/> end;<br/> end; { case }<br/> read(DataFile, hilfs); { remove <TAB> before next value }<br/> end;<br/><br/>begin<br/> assign(DataFile, FileName);<br/> reset(DataFile);<br/> StudentNo := 0;<br/> QuestionNo := 0;<br/> while not eof(DataFile) do<br/> begin<br/> inc(StudentNo);<br/> for QuestionNo := 1 to Questions do { read the individual question results for one student }<br/> begin<br/> QuestionData[QuestionNo, StudentNo].Score := ReadByte;<br/> QuestionData[QuestionNo, StudentNo].Letter := ReadChar;<br/> end; { for }<br/> AdmissionData[SudentNo].MCAT := ReadByte; { read the admissions data for that student }<br/> AdmissionData[SudentNo].MCBS := ReadByte;<br/> AdmissionData[SudentNo].MCPS := ReadByte;<br/> AdmissionData[SudentNo].MCVR := ReadByte;<br/> AdmissionData[SudentNo].MCWS := ReadChar;<br/> AdmissionData[SudentNo].OGPA := ReadFloat;<br/> AdmissionData[SudentNo].PGPA := ReadFloat;<br/> AdmissionData[SudentNo].Levl := ReadFloat;<br/> ReadSex(AdmissionData[StudentNo].Sex);<br/> for Exam := Low(ExamType) to High(ExamType) do<br/> begin<br/> ExamData[Exam, StudentNo].time := ReadTime;<br/> ExamData[Exam, StudentNo].total := ReadByte;<br/> ExamData[Exam, StudentNo].percent := ReadFloat;<br/> ReadResult(ExamData[Exam, StudentNo].result);<br/> end; { for }<br/> end; { while }<br/>end; { ReadDataFile }<br/><br/>begin<br/> ReadDataFile;<br/>end.<br/> <br/></div></div> <br><br><table cellpadding="0" cellspacing="0" border="0"><tr><td style="font-family:verdana; font-size:12px; line-height:17px;border-top:1px solid #000000">Ihr WEB.DE Postfach immer dabei: die kostenlose WEB.DE Mail App für iPhone und Android. <br><a href="https://produkte.web.de/freemail_mobile_startseite/"><b>https://produkte.web.de/freemail_mobile_startseite/</b></a></td></tr></table>
</body></html>