Search code examples
navision

How do you loop through text file in C/AL(Navision)


I am trying to create a function that will parse through a text file that has two columns: customer number and file address. As the function loops through each record in the text file, have it search for a Customer record based upon the first column, and if found, insert a record link whose URL is the value of the file address column. I am using Microsoft Dynamics NAV so it involves C/AL. any insights would be much appreciated since I cannot seem to find what I want when I google it.


Solution

  • Try these:

    //variable:
    //Name: recDir, DataType: Record,    Subtype: File(2000000022)
    //Name: txtPath, DataType: Text, Length: 100
    //coding:
    txtPath:='C:\temp\';
    recDir.RESET;
    recDir.SETRANGE(Path,txtPath);
    recDir.SETRANGE("Is a file",TRUE);
    IF recDir.FIND('-') THEN BEGIN
        REPEAT 
            MESSAGE('%1',recDir.Name); 
         UNTIL recDir.NEXT=0;
    END;