validation

I have to complete an assigment in Pascal which is basically a wages program for output in which each record field is validated according to type, size etc...for any field that fails the validation the record must be written to an error file.
This is the bit that has thrown me. The actual validation seems ok but how do I get the info to an info file? Do I set up a text file to be written to...please help as the rest of the program is ok apart from this...... [:- ( }

Comments

  • : I have to complete an assigment in Pascal which is basically a wages program for output in which each record field is validated according to type, size etc...for any field that fails the validation the record must be written to an error file.
    : This is the bit that has thrown me. The actual validation seems ok but how do I get the info to an info file? Do I set up a text file to be written to...please help as the rest of the program is ok apart from this...... [:- ( }
    :
    To my knowledge yes to a TEXT file.

    I have been doing the same thing and yes TEXT file is a way.
    I am at a libary and my pascal is at home
    Yours Sincerely Michael

  • : I have to complete an assigment in Pascal which is basically a wages program for output in which each record field is validated according to type, size etc...for any field that fails the validation the record must be written to an error file.
    : This is the bit that has thrown me. The actual validation seems ok but how do I get the info to an info file? Do I set up a text file to be written to...please help as the rest of the program is ok apart from this...... [:- ( }

    look up the [b]append()[/b] and [b]blockread()[/b],[b]blockwrite()[/b] procedures.
    the first is for opening a file for input after current EOF, the other 2 are for reading/writing records 2 a file.

    hope this helps :-)
    [blue]//Noam[/blue]

  • : : I have to complete an assigment in Pascal which is basically a wages program for output in which each record field is validated according to type, size etc...for any field that fails the validation the record must be written to an error file.
    : : This is the bit that has thrown me. The actual validation seems ok but how do I get the info to an info file? Do I set up a text file to be written to...please help as the rest of the program is ok apart from this...... [:- ( }
    :
    : look up the [b]append()[/b] and [b]blockread()[/b],[b]blockwrite()[/b] procedures.
    : the first is for opening a file for input after current EOF, the other 2 are for reading/writing records 2 a file.
    :
    : hope this helps :-)
    : [blue]//Noam[/blue]
    :
    Thanks for the advice. So I assign a text file purely for the records which fail the validation tests by using a write procedure ?. How exactly is this done? My reading of the write procedure is that i would incorporate a procedure within the program purely for validation which would then write to an error text file all the records that fail whilst those that pass the validation are sent for output. Any further clarification would be welcome. Once again thanks...

  • : Thanks for the advice. So I assign a text file purely for the records which fail the validation tests by using a write procedure ?. How exactly is this done? My reading of the write procedure is that i would incorporate a procedure within the program purely for validation which would then write to an error text file all the records that fail whilst those that pass the validation are sent for output. Any further clarification would be welcome. Once again thanks...

    yes.
    the write procedure can't determine what you want to send to the file it can only send a given thing to it..
    as for the actual validating procedure -
    if reading a number you can read a string and then go over it to check each of its cells (as it functions like an array of char) rather than having to mess with the 'invalid number' error you get when entering a letter instead of a number..
    any kind of string validation is just going over the cells and checking if they're in a certain range you're looking for.

    like, if you wanted to input a number in binary and transform it into decimal you read a string until all the cells that have a value have either '0' or '1'.

    thus, if all fields of a record pass a certain test they are written to screen, otherwise you put it in the file..

    i'm not sure i can give further clarification on this issue, it's pretty much covered..if you have more questions you'll need to specifically ask them :)
    [blue]//Noam[/blue]

  • : : Thanks for the advice. So I assign a text file purely for the records which fail the validation tests by using a write procedure ?. How exactly is this done? My reading of the write procedure is that i would incorporate a procedure within the program purely for validation which would then write to an error text file all the records that fail whilst those that pass the validation are sent for output. Any further clarification would be welcome. Once again thanks...
    :
    : yes.
    : the write procedure can't determine what you want to send to the file it can only send a given thing to it..
    : as for the actual validating procedure -
    : if reading a number you can read a string and then go over it to check each of its cells (as it functions like an array of char) rather than having to mess with the 'invalid number' error you get when entering a letter instead of a number..
    : any kind of string validation is just going over the cells and checking if they're in a certain range you're looking for.
    :
    : like, if you wanted to input a number in binary and transform it into decimal you read a string until all the cells that have a value have either '0' or '1'.
    :
    : thus, if all fields of a record pass a certain test they are written to screen, otherwise you put it in the file..
    :
    : i'm not sure i can give further clarification on this issue, it's pretty much covered..if you have more questions you'll need to specifically ask them :)
    : [blue]//Noam[/blue]
    :

    I have followed thru alll since the first(beginning of the validation);

    There is a saying trust that the operater using the program is stupid(don't tell them that).

    And with this in mind the robust vailidation of data is the way to go.

    Like say we want a N or Y only

    var ok:char;{used to validate the data entered}
    character:char;{entered}
    begin
    ok:='N';
    while ok='N' do
    begin
    write('Enter Y for yes and N for No :');
    readln(character);
    character:=upcase(character);{allowing Y,y,N,n}
    if character='Y' then
    ok:='Y'
    else
    if character='N' then
    ok:='Y'
    else
    begin
    writeln('Wrong character enetered -',character);
    writeln('Please try again!');
    end;{if character ok}
    end;{when character is Y or N}
    end;

    {I have been validating characters when I am doing real paid programs}
    {Michael}

  • : : : Thanks for the advice. So I assign a text file purely for the records which fail the validation tests by using a write procedure ?. How exactly is this done? My reading of the write procedure is that i would incorporate a procedure within the program purely for validation which would then write to an error text file all the records that fail whilst those that pass the validation are sent for output. Any further clarification would be welcome. Once again thanks...
    : :
    : : yes.
    : : the write procedure can't determine what you want to send to the file it can only send a given thing to it..
    : : as for the actual validating procedure -
    : : if reading a number you can read a string and then go over it to check each of its cells (as it functions like an array of char) rather than having to mess with the 'invalid number' error you get when entering a letter instead of a number..
    : : any kind of string validation is just going over the cells and checking if they're in a certain range you're looking for.
    : :
    : : like, if you wanted to input a number in binary and transform it into decimal you read a string until all the cells that have a value have either '0' or '1'.
    : :
    : : thus, if all fields of a record pass a certain test they are written to screen, otherwise you put it in the file..
    : :
    : : i'm not sure i can give further clarification on this issue, it's pretty much covered..if you have more questions you'll need to specifically ask them :)
    : : [blue]//Noam[/blue]
    : :
    :
    : I have followed thru alll since the first(beginning of the validation);
    :
    : There is a saying trust that the operater using the program is stupid(don't tell them that).
    :
    : And with this in mind the robust vailidation of data is the way to go.
    :
    : Like say we want a N or Y only
    :
    : var ok:char;{used to validate the data entered}
    : character:char;{entered}
    : begin
    : ok:='N';
    : while ok='N' do
    : begin
    : write('Enter Y for yes and N for No :');
    : readln(character);
    : character:=upcase(character);{allowing Y,y,N,n}
    : if character='Y' then
    : ok:='Y'
    : else
    : if character='N' then
    : ok:='Y'
    : else
    : begin
    : writeln('Wrong character enetered -',character);
    : writeln('Please try again!');
    : end;{if character ok}
    : end;{when character is Y or N}
    : end;
    :
    : {I have been validating characters when I am doing real paid programs}
    : {Michael}
    : Thanks to both Noam and Michael for their help. I know how to go with this now and if I encounter any more difficulties I'll post some frantic help......cheers cats:))


  • : : : : Thanks for the advice. So I assign a text file purely for the records which fail the validation tests by using a write procedure ?. How exactly is this done? My reading of the write procedure is that i would incorporate a procedure within the program purely for validation which would then write to an error text file all the records that fail whilst those that pass the validation are sent for output. Any further clarification would be welcome. Once again thanks...
    : : :
    : : : yes.
    : : : the write procedure can't determine what you want to send to the file it can only send a given thing to it..
    : : : as for the actual validating procedure -
    : : : if reading a number you can read a string and then go over it to check each of its cells (as it functions like an array of char) rather than having to mess with the 'invalid number' error you get when entering a letter instead of a number..
    : : : any kind of string validation is just going over the cells and checking if they're in a certain range you're looking for.
    : : :
    : : : like, if you wanted to input a number in binary and transform it into decimal you read a string until all the cells that have a value have either '0' or '1'.
    : : :
    : : : thus, if all fields of a record pass a certain test they are written to screen, otherwise you put it in the file..
    : : :
    : : : i'm not sure i can give further clarification on this issue, it's pretty much covered..if you have more questions you'll need to specifically ask them :)
    : : : [blue]//Noam[/blue]
    : : :
    : :
    : : I have followed thru alll since the first(beginning of the validation);
    : :
    : : There is a saying trust that the operater using the program is stupid(don't tell them that).
    : :
    : : And with this in mind the robust vailidation of data is the way to go.
    : :
    : : Like say we want a N or Y only
    : :
    : : var ok:char;{used to validate the data entered}
    : : character:char;{entered}
    : : begin
    : : ok:='N';
    : : while ok='N' do
    : : begin
    : : write('Enter Y for yes and N for No :');
    : : readln(character);
    : : character:=upcase(character);{allowing Y,y,N,n}
    : : if character='Y' then
    : : ok:='Y'
    : : else
    : : if character='N' then
    : : ok:='Y'
    : : else
    : : begin
    : : writeln('Wrong character enetered -',character);
    : : writeln('Please try again!');
    : : end;{if character ok}
    : : end;{when character is Y or N}
    : : end;
    : :
    : : {I have been validating characters when I am doing real paid programs}
    : : {Michael}
    : : Thanks to both Noam and Michael for their help. I know how to go with this now and if I encounter any more difficulties I'll post some frantic help......cheers cats:))
    :
    :
    Velvet Well Done
    Noam is a tremendous programmer. And I am happy you have had success in programming.
    I am on designing a Accounting Package and Coding
    Michael

  • : : : : : Thanks for the advice. So I assign a text file purely for the records which fail the validation tests by using a write procedure ?. How exactly is this done? My reading of the write procedure is that i would incorporate a procedure within the program purely for validation which would then write to an error text file all the records that fail whilst those that pass the validation are sent for output. Any further clarification would be welcome. Once again thanks...
    : : : :
    : : : : yes.
    : : : : the write procedure can't determine what you want to send to the file it can only send a given thing to it..
    : : : : as for the actual validating procedure -
    : : : : if reading a number you can read a string and then go over it to check each of its cells (as it functions like an array of char) rather than having to mess with the 'invalid number' error you get when entering a letter instead of a number..
    : : : : any kind of string validation is just going over the cells and checking if they're in a certain range you're looking for.
    : : : :
    : : : : like, if you wanted to input a number in binary and transform it into decimal you read a string until all the cells that have a value have either '0' or '1'.
    : : : :
    : : : : thus, if all fields of a record pass a certain test they are written to screen, otherwise you put it in the file..
    : : : :
    : : : : i'm not sure i can give further clarification on this issue, it's pretty much covered..if you have more questions you'll need to specifically ask them :)
    : : : : [blue]//Noam[/blue]
    : : : :
    : : :
    : : : I have followed thru alll since the first(beginning of the validation);
    : : :
    : : : There is a saying trust that the operater using the program is stupid(don't tell them that).
    : : :
    : : : And with this in mind the robust vailidation of data is the way to go.
    : : :
    : : : Like say we want a N or Y only
    : : :
    : : : var ok:char;{used to validate the data entered}
    : : : character:char;{entered}
    : : : begin
    : : : ok:='N';
    : : : while ok='N' do
    : : : begin
    : : : write('Enter Y for yes and N for No :');
    : : : readln(character);
    : : : character:=upcase(character);{allowing Y,y,N,n}
    : : : if character='Y' then
    : : : ok:='Y'
    : : : else
    : : : if character='N' then
    : : : ok:='Y'
    : : : else
    : : : begin
    : : : writeln('Wrong character enetered -',character);
    : : : writeln('Please try again!');
    : : : end;{if character ok}
    : : : end;{when character is Y or N}
    : : : end;
    : : :
    : : : {I have been validating characters when I am doing real paid programs}
    : : : {Michael}
    : : : Thanks to both Noam and Michael for their help. I know how to go with this now and if I encounter any more difficulties I'll post some frantic help......cheers cats:))
    : :
    : :
    : Velvet Well Done
    : Noam is a tremendous programmer. And I am happy you have had success in programming.
    : I am on designing a Accounting Package and Coding
    : Michael
    :

    Michael
    As you were so kind to help I wonder if you can scan the code and tell me if u think it is going wrong....

    [b]procedure[/b] ValidationEmployeeRecord;

    [b]const[/b]
    MaxLen:4;

    [b]var[/b]
    ok:=boolean;
    Len, I : integer;

    [b]begin[/b]

    ok:=true;
    Len:=Length(TaxCode);
    [b]if[/b]EmployRecord.ClockNo<1000[b]or[/b]>9999[b]then[/b]
    ok:=false;
    [b]else[/b]
    [b]for[/b]I:=1[b]to[/b]MaxLen[b]do[/b]
    [b]begin[/b]
    [b]case[/b] I [b]of[/b]
    1..3: [b]if not[/b](EmployRecord.Taxcode[I] [b]in[/b][0..9])[b]then[/b]
    [b]begin[/b]
    ok:=false;
    [b]end[/b];
    4:[b]if not[/b](EmployRecord.Taxcode[I][b]in[/b]("L"[b]or[/b]"H"))[b]then[/b]
    [b]begin[/b]
    ok:=false;
    [b]end[/b];
    [b]end[/b] {end for}
    [b]end[/b]; {end case}
    [b]if[/b]EmployRecord.ShiftAttended[b]not in[/b][1..7][b]then[/b]
    ok:=false;
    [b]if not[/b]ok [b]then[/b]
    writeln(ErrorFile, EmployRecord);
    [b]end[/b];

    {does this seem ok or do u suggest any amendments? Thank u loads in anicipation of ure help...
    [b]Velvet[/b].....:))


  • : [b]end[/b] {end for}
    : [b]end[/b]; {end case}

    just so you don't get confused in the future - the first end; is for the case and the 2nd for the for..
    it goes in order of "closing the closest begining"..
    closest in pascal tearms means the innermost begin or 'begin-like' statement (record, case, object, asm etc.).

    : writeln(ErrorFile, EmployRecord);
    i just haven't tried writing records directly yet but if it works then go ahead :)

    haven't seen your employeerecord record, but it looks like the code is ok..
    you don't have to do begin..end; for 1 thing..
    //Noam

  • : : [b]end[/b] {end for}
    : : [b]end[/b]; {end case}
    :
    : just so you don't get confused in the future - the first end; is for the case and the 2nd for the for..
    : it goes in order of "closing the closest begining"..
    : closest in pascal tearms means the innermost begin or 'begin-like' statement (record, case, object, asm etc.).
    :
    : : writeln(ErrorFile, EmployRecord);
    : i just haven't tried writing records directly yet but if it works then go ahead :)
    :
    : haven't seen your employeerecord record, but it looks like the code is ok..
    : you don't have to do begin..end; for 1 thing..
    : //Noam
    : thanks [b]noam[/b]. I know what u mean re closing, an oversight on my part so cheers for pointing it out. The record will write like this so I think everything is Ok now. It's been a slow process as I have a new born but it's been cool for all your help...cheers mate.......
    [b]Velvet[/b]:))


  • : : : : : : Thanks for the advice. So I assign a text file purely for the records which fail the validation tests by using a write procedure ?. How exactly is this done? My reading of the write procedure is that i would incorporate a procedure within the program purely for validation which would then write to an error text file all the records that fail whilst those that pass the validation are sent for output. Any further clarification would be welcome. Once again thanks...
    : : : : :
    : : : : : yes.
    : : : : : the write procedure can't determine what you want to send to the file it can only send a given thing to it..
    : : : : : as for the actual validating procedure -
    : : : : : if reading a number you can read a string and then go over it to check each of its cells (as it functions like an array of char) rather than having to mess with the 'invalid number' error you get when entering a letter instead of a number..
    : : : : : any kind of string validation is just going over the cells and checking if they're in a certain range you're looking for.
    : : : : :
    : : : : : like, if you wanted to input a number in binary and transform it into decimal you read a string until all the cells that have a value have either '0' or '1'.
    : : : : :
    : : : : : thus, if all fields of a record pass a certain test they are written to screen, otherwise you put it in the file..
    : : : : :
    : : : : : i'm not sure i can give further clarification on this issue, it's pretty much covered..if you have more questions you'll need to specifically ask them :)
    : : : : : [blue]//Noam[/blue]
    : : : : :
    : : : :
    : : : : I have followed thru alll since the first(beginning of the validation);
    : : : :
    : : : : There is a saying trust that the operater using the program is stupid(don't tell them that).
    : : : :
    : : : : And with this in mind the robust vailidation of data is the way to go.
    : : : :
    : : : : Like say we want a N or Y only
    : : : :
    : : : : var ok:char;{used to validate the data entered}
    : : : : character:char;{entered}
    : : : : begin
    : : : : ok:='N';
    : : : : while ok='N' do
    : : : : begin
    : : : : write('Enter Y for yes and N for No :');
    : : : : readln(character);
    : : : : character:=upcase(character);{allowing Y,y,N,n}
    : : : : if character='Y' then
    : : : : ok:='Y'
    : : : : else
    : : : : if character='N' then
    : : : : ok:='Y'
    : : : : else
    : : : : begin
    : : : : writeln('Wrong character enetered -',character);
    : : : : writeln('Please try again!');
    : : : : end;{if character ok}
    : : : : end;{when character is Y or N}
    : : : : end;
    : : : :
    : : : : {I have been validating characters when I am doing real paid programs}
    : : : : {Michael}
    : : : : Thanks to both Noam and Michael for their help. I know how to go with this now and if I encounter any more difficulties I'll post some frantic help......cheers cats:))
    : : :
    : : :
    : : Velvet Well Done
    : : Noam is a tremendous programmer. And I am happy you have had success in programming.
    : : I am on designing a Accounting Package and Coding
    : : Michael
    : :
    :
    : Michael
    : As you were so kind to help I wonder if you can scan the code and tell me if u think it is going wrong....
    :
    : [b]procedure[/b] ValidationEmployeeRecord;
    :
    : [b]const[/b]
    : MaxLen:4;
    :
    : [b]var[/b]
    : ok:=boolean;
    : Len, I : integer;
    :
    : [b]begin[/b]
    :
    : ok:=true;
    : Len:=Length(TaxCode);{were is this TaxCode coming from??}
    : [b]if[/b]EmployRecord.ClockNo<1000[b]or[/b]>9999[b]then[/b]
    : ok:=false;{EmployeeRecord.ClockN0 were is its declaration}
    : [b]else[/b]
    : [b]for[/b]I:=1[b]to[/b]MaxLen[b]do[/b]
    : [b]begin[/b]
    : [b]case[/b] I [b]of[/b]
    : 1..3: [b]if not[/b](EmployRecord.Taxcode[I] [b]in[/b][0..9])[b]then[/b]
    : [b]begin[/b]
    : ok:=false;
    : [b]end[/b];
    : 4:[b]if not[/b](EmployRecord.Taxcode[I][b]in[/b]("L"[b]or[/b]"H"))[b]then[/b]
    : [b]begin[/b]
    : ok:=false;
    : [b]end[/b];
    : [b]end[/b] {end for}
    : [b]end[/b]; {end case}
    : [b]if[/b]EmployRecord.ShiftAttended[b]not in[/b][1..7][b]then[/b]
    : ok:=false;
    : [b]if not[/b]ok [b]then[/b]
    : writeln(ErrorFile, EmployRecord);
    : [b]end[/b];
    :
    : {does this seem ok or do u suggest any amendments? Thank u loads in anicipation of ure help...
    : [b]Velvet[/b].....:))
    :
    :
    Velvet I have made some Remarks thru..

    If employeerecord is a record in pascal I understand.
    Yet for a procedure to use it it needs to be passed to it.
    ie

    procdeure procedurename({ie}apples:integer var numbers:integer);
    var {of local variables}
    begin
    {whatever the design and then coded}
    end;{procedurename}
    var
    fruit:string;
    numberof:integer;
    begin{main}
    procedurename(fruit,numberof);
    end.{main}

    Note the above of passing to and from a procedure.

    I see what you are trying to do but first try the design

    and then test it, then code...

    Like

    wages
    open the employeefile
    while not the end of file employeefile
    open the hoursworked
    from hoursworked employeenumber, hours
    from employeefile employeenumber
    if employeenumber is ok then
    process employeefile and hoursworked
    end while
    close both files

    process employee file and hoursworked
    .....
    now just test if the desihn is going to work
    and if happy then do the next design of process..

    I am knowing that design is crucial as we get lost in hack programming. That is design as you code. And it doesn't work on Programs over 100 lines

    My accounting program is at the moment 239 lines and I have yet to desgin the sub modules to do the work.

    Like the first design
    Which I had another Programmer check the design
    He said yes after I had tested it. And that is the top level
    I have been checking my design before coding.

    I know that the accounting desgin and little coded so far is 3hours.
    I have had to make security on data.
    I know accounting
    Ledger of and formular assests-liabilities=equity.
    and with this need to be able to create, income, expences
    check the date if end of month
    process Profit-Surplus-Loss-Deficeit of income and expences
    fromthe process up date the ledger

    Now until I am happy with the desdign I do not code

    Say we all wanting a project to work on
    and I beleive we could and then we all have the design, test data
    and then the code
    and it would be an international success story

    Anyway enough about that

    I hope I am helping
    Michael


  • [code]
    Try to change:

    if EmployRecord.ClockNo<1000 or >9999 then ok:=false;

    into

    if (EmployRecord.ClockNo<1000) or (EmployRecord.ClockNo>9999)
    then ok:=false;

    The previous condition is invalid (at least in TP).


    Iby

    [/code]







    : [b]else[/b]
    : [b]for[/b]I:=1[b]to[/b]MaxLen[b]do[/b]
    : [b]begin[/b]
    : [b]case[/b] I [b]of[/b]
    : 1..3: [b]if not[/b](EmployRecord.Taxcode[I] [b]in[/b][0..9])[b]then[/b]
    : [b]begin[/b]
    : ok:=false;
    : [b]end[/b];
    : 4:[b]if not[/b](EmployRecord.Taxcode[I][b]in[/b]("L"[b]or[/b]"H"))[b]then[/b]
    : [b]begin[/b]
    : ok:=false;
    : [b]end[/b];
    : [b]end[/b] {end for}
    : [b]end[/b]; {end case}
    : [b]if[/b]EmployRecord.ShiftAttended[b]not in[/b][1..7][b]then[/b]
    : ok:=false;
    : [b]if not[/b]ok [b]then[/b]
    : writeln(ErrorFile, EmployRecord);
    : [b]end[/b];
    :
    : {does this seem ok or do u suggest any amendments? Thank u loads in anicipation of ure help...
    : [b]Velvet[/b].....:))
    :
    :


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories