Announcement

Collapse
No announcement yet.

Comparing every field record

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Comparing every field record

    I am new to this forum but learn scriptcase for months now still can not get what i want.
    "I have a grid application with records of weight with 10 records, I would like to compare each weight by the difference of less than or equal to 30grams and match them as paired." (needs to be sorted out first in decending order)
    I have the following records:
    mangoes 130grams
    banana 500grams
    apple 150grams
    grapes 530grams
    the result should be like
    grapes 530grams 1
    banana 500grams 1
    apple 150grams 2
    mangoes 130 grams 2

    Please help me as one of my project in class.

  • #2
    I dont understand your request, can you make it more understandable?

    Comment


    • #3
      Originally posted by dmaico View Post
      I am new to this forum but learn scriptcase for months now still can not get what i want.
      "I have a grid application with records of weight with 10 records, I would like to compare each weight by the difference of less than or equal to 30grams and match them as paired." (needs to be sorted out first in decending order)
      I have the following records:
      mangoes 130grams
      banana 500grams
      apple 150grams
      grapes 530grams
      the result should be like
      grapes 530grams 1
      banana 500grams 1
      apple 150grams 2
      mangoes 130 grams 2

      Please help me as one of my project in class.
      I think you need to look at the sql to select the required data. You need to select count(*) and apply a break on fruit. In the where you need to specify the match. I suggest you try to create a valid sql statement in the database of choice until it returns the required data. Then you can start coding in scriptcase.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development
      www.scriptcase.eu / www.scriptcase.nl

      Comment


      • #4
        First I want to sort my database by grams.
        I have a table called fruits with the files on grams. I want to to sort grams in descending order
        I know the SELECT command in SQL like
        SELECT "weight"
        FROM fruits
        ORDER by DEC
        But how can i insert it to my scriptcase under onrecord or onload?
        so that the grid application will display all fruits with weight in descending order?

        Needs some help with this.

        Comment


        • #5
          how can i execute this statement in grid application so that i will sort my table

          $sql = "SELECT weight
          FROM weight_sub_table
          ORDER BY
          weight DESC ";

          It doesnt affect the grid display, i know the is missing command but how can i continue with this?

          Comment


          • #6
            1.jpg

            2.jpg

            I want show result in grid as i attached second image
            please check...

            Comment


            • #7
              Originally posted by dmaico View Post
              how can i execute this statement in grid application so that i will sort my table
              Put your SQL Code in Grid / SQL, not in onRecord or onLoad ...
              Best regards: - Reinhard -

              I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

              Comment


              • #8
                Thank you very much for that little sql trick, I can sort the table, and i can see my data sorted. thanks again RHS

                After the data has been sorted I placed the SELECT command onrecord event to compare the each record on my table, I can compare the first field but I can not see the comparison on the second field. I know a little idea on how to do it on the own way, but in scriptcase, i can not do this

                My problem is this comparison:
                I want to compare the each field record in weight and compare with the next record if their difference is <= to 30
                if this is true match number will be inserted on both record field.
                Then the third and the fourth record will then be compared if their difference is <= 30
                if this is true then match number will be inserted on both record field, and so on.

                To do this, I use the code: but only the first and the second record was compared and all filed was inserted number 1.

                $sql=("SELECT weight,match_num
                FROM weight_sub_table
                ORDER BY weight DESC");


                sc_lookup(ds,$sql);

                $first = {ds[0][0]};
                $second ={ds[1][0]};

                /*compute of the difference*/
                $diff = $first - $second;

                /*if statement*/

                if($diff <= 30 )
                {
                $match_num = $match_num + 1;
                {ds[0][1]} = $match_num;
                {ds[1][1]} = $match_num;

                }
                else
                {
                sc_alert("needs to proceed to another record");
                exit();
                }


                What i really want is to have a table with this picture1 and the result will be in this picture2

                Picture1.pngPicture2.png


                I just manipulated the file.

                Thanks again, please help me with this.

                Comment

                Working...
                X