Code conversion tool

pvarpvar Member Posts: 157
I am in the process of doing an object upgrade from 3.6 to 2009. The commands FIND('-') and FIND('+') have been replaced by FINDFIRST, FINDSET and FINDLAST in 2009. Is there a tool that I can use to replace all the old find's with the new find's? we have a lot of custom code.

Thanks

Comments

  • bbrownbbrown Member Posts: 3,268
    FIND('-') and FIND('+') were not replaced by FINDFIRST, FINDSET and FINDLAST. These are new commands that are available in addition to the older command. Depending on the situation you may not always want to replace the older commands.
    There are no bugs - only undocumented features.
  • reijermolenaarreijermolenaar Member Posts: 256
    I am afraid that this cannot be automated.
    The command FIND('-') can be converted to 'FINDSET', 'FINDFIRST' AND 'NOT ISEMPTY'.
    It depends on the situation.

    To replace the FIND('+') with FINDLAST you can export all objects in textformat and do a replace with e.g. notepad.
    Reijer Molenaar
    Object Manager
  • pvarpvar Member Posts: 157
    I heard that the new commands are more efficient that the old ones and recommended. Is there any particular situation where the old command works better than the new one?

    As reijermolenaar said I could replace all the find('+) with FINDLAST with a find & replace command in some editor. But Find('-') needs to be replaced with FINDFIRST or FINDSET depending on if you are trying to fetch just the first record or a set of records and that is where I need some help.

    Another reason I wanted to do this is for consistency in the code because the base code has the new find commands every where.
  • bbrownbbrown Member Posts: 3,268
    FIND('+') is not always functionally equilalent to FINDLAST.

    The new commands are not used everywhere in the new code.
    There are no bugs - only undocumented features.
  • bbrownbbrown Member Posts: 3,268
    When looping thru very large datasets the old commands can be better to use. There was a thread discussing this but I can't seem to find it.
    There are no bugs - only undocumented features.
  • davmac1davmac1 Member Posts: 1,283
    I think the findset in version 4 and 5 pull in the first 500 rows. In NAV2009 that drops to 50.
    So, I think that means if your working set is larger, you should use the old commands.
    Plus if you are having to modify the key, the findset has to refresh the set after each update.
  • bbrownbbrown Member Posts: 3,268
    The number of records retreived by FINDSET is determined by the "record set" in the DB setup. But setting this to high can cause other issues.

    Another limitation is FINDSET can't use ascending recordsets.
    There are no bugs - only undocumented features.
  • pvarpvar Member Posts: 157
    Where exactly is that setup?

    Also what happens when you set a value and the record set has more than that?
  • bbrownbbrown Member Posts: 3,268
    File - Database - Alter
    There are no bugs - only undocumented features.
  • kinekine Member Posts: 12,562
    I recommend to read more about the commands on this forum. You will see that it is not just simple replacement. FINDLAST and FINDFIRST are good only when you are not looping through the records. ISEMPTY is good if you just wants to know if there is something or not but you do not need the data. FINDSET is good for looping, but have two parmters which can differ based on the context. etc... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Read this to start with: How to work with record-variables?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • pvarpvar Member Posts: 157
    Thanks to all for your valuable suggestions. I think I could summarize what every one says to the following

    Use ISEMPTY to see if there are any records exists in the table
    Use FINDFIRST or FINDLAST if you want to find just the first or last record
    Use FINDSET if you want to loop through a record set and the record set is small and loop in ASCENDING order
    Use FIND('-') if you want to loop through a record set when the record set is large or loop in DESCENDING order

    I still didn't know what happens in a situation where you use FINDSET and it returns a record set larger than what defined in the database setting. I don't think it is going to do anything really bad other than being a slow fetch.
  • ara3nara3n Member Posts: 9,256
    If the record set is greater than the 500 in 5.0 and 50 in 2009, then FINDSET after the last record will behave like find('-') and created server cursor and loop through it and return one record at a time.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.