Jump to content

karl Jonson

Members
  • Content Count

    24
  • Joined

  • Last visited

Posts posted by karl Jonson


  1. Hi,
    I am reading a database & adding to a file the following info:
       

    user_name, surname, date of birth, phone number


    One customer can have multiple records in db.
    Which is the best way to keep track of data I am adding to text file & make sure the data I am copying in it is unique

    Loop through records in db
      if combination user_name, surname, date of birth, phone number doesn't exist in text file then
        add
      else
        read next record

    TIA
     


  2. Hi,
    I have similar student data:

    FirstName
    LastName
    DOB
    DegreeType
    Course1
    Course1StartDate
    Course2EndDate

    Also, I have rules similar to these:

      FirstName does not match pattern
      LastName does not match pattern
      Student age cannot be greater than 110 or less than 15
      A language degree must have a least one language course
      A language course cannot be given for a non-laguage degree
      Course start date can't be after end date

    These are just examples.  I have about 100 data fields & 50 rules.

    Which is the best way to validate student data against these rules ?
    If student data is valid add to xml if not then add to a list or erroneous records.

    TIA


  3. Hi,
    If I had these options in TListView:
    None
    Not Known
    OptionOne
    OptionTwo

     

    Which is the best way to implement this logic:
    'None' option cannot be selected in conjunction with another options
    'Not Known' option cannot be selected in conjunction with another options

    TIA


  4. Hi,
    I am trying to process results to this question:
    What optional subjects do you study?
    Results could be:
    1 Option1
    2 Option2
    8 None
    9 NotKnown

     

    I have the results in a SQL query result e.g.

    OptionCode
    1
    2
    9

     

    I would like to implement these rules on the query result:
    If duplicate codes then invalid result
    if 8 & another code then invalid result
    if 9 & another code then invalid result

     

    [Options table]
    1 Option1
    2 Option2
    8 None
    9 NotKnown
    
    [Answers table]
    Student Answer
    100     1
    100     2
    
    101     1
    101     9
    
    Student 100 answers are valid.
    Student 101 answers are not valid because they break rule number3

     

    Which is the best way to implement these 3 rules ?

     

    I want to do this:

    ValidateStudentAnswers(100) => result : valid

    ValidateStudentAnswers(101) => result : not valid

     

    TIA


  5. 2 minutes ago, Lajos Juhász said:

    There is no reason to verify the data after you generated the XML. It's always the best to verify in case the data is incorrect to change it and as a last step to generate the output.

    These are the steps I had in mind:

    User clicks on "Generate XML" button

    App generates XML

    App validates XML

    A report containing errors is generated & displayed to user

    User goes through errors report, correct their data, then click on "Generate XML" again.


  6. 31 minutes ago, ertank said:

    Is there a reason for you not to check each XML item against these rules at the time of XML generation?

    There's no reason.  That's something I need to consider.  

     

    These are the steps I had in mind:

    User clicks on "Generate XML" button

    App generates XML

    App validates XML

    A report containing errors is generated & displayed to user

    User goes through errors report, correct their data, then click on "Generate XML" again.


  7. 7 minutes ago, Lars Fosdal said:

    Do you want to do it in the generating app, or do you want to check the XML by validating against a schema (xsd)?

    Personally, I would have done it in Delphi. So much faster and a lot less trouble.

    I would like to validate the XML in the generating app but not against an XSD schema.

    So my app generates the XML & as a last step I would like to validate the XML against a list of rules, e.g.

    A book must have an author.
    A book price cannot exceed $100

    A book publisher must exist in a pre-defined list.

    A book ISBN must be unique

    ....

    Then generate a report at the end of validation which lists all errors found.

    Thanks.

     


  8. XML validation.
    I have an Object Pascal application which generates XML similar to this one:

    <book>
      <name>Anna Karenina</name> 
      <author>Leo Tolstoy</author> 
      <publisher>The Russian Messenger</publisher>
      <price>$16.79</price>
    </book>


    Which is the best way to add code which validates the above XML (in the generating app) ?

    I would like to make sure that: 
    A book must have an author.
    A book price cannot exceed $100

    TIA


  9. I have a DBEdit linked to a integer-field in a table & everything works fine but now I'd like to allow user to enter many integers separated by commas in the DBEdit.
    So when user types 1,2,3 three records are inserted in the table & without the posting failing.
    How can I achieve this ?
    TIA


  10. Hi,
    I'm using a procedure which uses a TLabel parameter & sets the caption of the label:

     

    prcedure GetString(param1: string; param2:string; myLabel: TLabel);
    Begin
      myLabel.caption := GetDescription()
    End


     
    Everything works fine & I don't want to break it as it's called from different places.
    Now I'd like to be able to sometimes pass it TMemo and display multiple lines in the TMemo component:

     

      myMemo.lines.Add(GetDescription());

    I'd like to be able to say if component is TLabel then do this but if it's TMemo then do that.

    TIA


  11. Hi,
    I'm using a ButtonEdit component to display a code selected by user & I also use a label to display the description of that code.
    If user clicks on the ButtonEdit a form is launched & user selects 'NGO', NGO will display in the ButtonEdit and description is fetched & displayed in the label next to it:

    NGO :Non governmental organization
    This works fine but now I'd like to allow user to multiselect codes.
    Which component allows me to multiselect codes & display description of those codes ?

    It's a list of 4 codes & user can select from 1 to 4 codes.
    Thanks.


  12. 26 minutes ago, Anders Melander said:

    Assuming you meant AnsiString and not AnsiChar (it doesn't make sense to compare 13 bytes to 1 ansichar):

    
    function Compare(const Bytes: TByteArray; const Str: AnsiString): boolean;
    begin
      Result := (Length(Str) = SizeOf(Bytes)) and (CompareMem(@Str[1], @Bytes[0], SizeOf(Bytes));
    end;

    Thanks.

    It's ansichar type.

    I need to check if MyByteArray = MyansiChar (eg. control character EOT)

×