3 Replies Latest reply: May 15, 2014 9:53 AM by David Musgrove RSS

    Returning the position of a character in a file

    David Musgrove



      I have written a Model for a very long Oracle Report that returns data, and need to compare it with another model that is being run on the same report.


      For various reasons of duplicate data etc. I need to return where the data came from in the file, so that the 2 extracts can be compared.


      I have used the page and line functions ( numeric ) to return what i think should be the location of the data, but cannot combine these ie ( Page2005line156 ) as Monarch says there is a data mismatch . I have tried converting the page and line functions to strings and failed there too! Anyone any ideas as to how to do this easily?. Im using Monarch 9pro but restricting what i can do to V8Standard as this is what the end users have. I think I may have brain fade, but I cannot figure out how to do it.


      Cheers!!!  [img]smile.gif[/img]

        • Returning the position of a character in a file
          Data Kruncher

          Hi David,


          Create a new character field and give it, say, a width of 20 positions, with the following formula:


          [font="courier"]"Page"Trim(Str(Page()))"Line"+Trim(Str(Line()))  /font[/quote]I think that'll do it for you.



          • Returning the position of a character in a file
            Grant Perkins



            If you wanted a numeric result you could use a calculated field that multiplied the Page number result by 1000 and then added the line number (assuming you need more that 99 lines but not more than 999.)


            If you choose a character field - like Page2005Line156 - something along the lines of a calculated field like this should work;

            [font="courier"]"Page"STR(Page())"Line"+STR(Line())[/font][/quote]The numeric solution may have some benefits if you want to check by calculating differences in page/line combinations I suppose.


            Does this help at all?





            edit : Dang the Kruncher fellow beat me to it again! ....


            Good advice the the TRIM function of course.


            Alternatively fixing the number of characters and inserting leading zeros may also have a part to play, maybe only on the line number.

            • Returning the position of a character in a file
              David Musgrove

              Thanks both for the above. I will try it out and hopefully my problem is solved!!