Dialog

ikik Member Posts: 22
edited 2004-02-02 in Navision Attain
Can anybody send description, sample of work with
variables Dialog type.

Thanx.

Comments

  • SbhatSbhat Member Posts: 301
    Hi,

    Here is an example of Dialog.

    First define a global variable Window type Dialog.

    Example :

    Salesline.setrange("document no.",Saleshead."no.");
    if salesline.find('-') then begin
    window.open('Updating Sales line for location code ####1###);
    repeat
    salesline."salesperson code" := Saleshead."salesperson code";
    salesline.modify
    window.update(1,salesline."document no."); until salesline.next = 0;
    end;

    Hope this helps !!!!

    Regards
    Suresh.
  • eromeineromein Member Posts: 589
    I would like to add that a dialog si very, very, very, very slow. I strongly recommend you keep the update of a dialog window to an absolute minimum...

    Often the update of a dialog in a report costs more time then the report runtime.

    A solution could be to update a dialog every x records.
    Dialog.open('Processing...\@1@@@@@@@@@@@@@@@@');
    
    IF NumbOfRecsProssed MOD 100 = 0 THEN
      window.update(1,ROUND((NumbOfRecsProssed / TotalNumbOfRecs) * 10000,1));
    
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Timo_LässerTimo_Lässer Member Posts: 481
    eromein wrote:
    I would like to add that a dialog si very, very, very, very slow. I strongly recommend you keep the update of a dialog window to an absolute minimum...
    [...]
    Therefore, in large processings, I update the dialog only if the percentage really change.
    So, the dialog will updated exactly 100 times, independent of the number of processed records.

    Example:
    IF SalesLine.FIND('-') THEN
      REPEAT
        // [...]
    
        // Percent, PercentOld = Integer
        Percent := ROUND((CurrRec / NoOfRecs) * 10000,1);
        IF Percent <> PercentOld THEN BEGIN
          Window.Update(1,Percent);
          Percent := PercentOld;
        END;
      UNTIL SalesLine.NEXT = 0;
    
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • DenSterDenSter Member Posts: 8,307
    So you use 6 lines of code where eromijn uses 2 for the same effect :)
  • Timo_LässerTimo_Lässer Member Posts: 481
    DenSter wrote:
    So you use 6 lines of code where eromijn uses 2 for the same effect :)
    Yes, that's right!
    But sometimes an update after every 100 records could be to fast anyway.
    So, in very large processings, this is the better way. :roll:
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • eromeineromein Member Posts: 589
    Sure, but you could do it like this...
    Dialog.open('Processing...\@1@@@@@@@@@@@@@@@@'); 
    
    IF NumbOfRecsProssed MOD (TotalNumbOfRecs * 10 / 100) = 0 THEN 
      window.update(1,
        ROUND((NumbOfRecsProssed / TotalNumbOfRecs) * 10000,1));
    


    Where (TotalNumbOfRecs * 10 / 100) is 10% if the total number of records. So in this sample you only update your dialog with steps of 10%.

    That is... If I didn't make a mistake here offcourse.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Timo_LässerTimo_Lässer Member Posts: 481
    eromein wrote:
    [...]
    Where (TotalNumbOfRecs * 10 / 100) is 10% if the total number of records. So in this sample you only update your dialog with steps of 10%.

    That is... If I didn't make a mistake here offcourse.
    I throw in the towel - you get the cup :wink:
    Your way is the most flexiblest because you can decide any percentage where the dialog should be updated. :roll:
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • eromeineromein Member Posts: 589
    I feel like Rocky!!! On top of that stairs!!! :wink::wink::wink:

    Tadadaaaaaa... Tadadaaaaaa... Tadadaaaaaa... etc...
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • DenSterDenSter Member Posts: 8,307
    If only Navision would allow more characters in the C/AL editor, you could have JUST ONE LINE!!! 8)
  • Timo_LässerTimo_Lässer Member Posts: 481
    DenSter wrote:
    If only Navision would allow more characters in the C/AL editor, you could have JUST ONE LINE!!! 8)
    The C/AL Editor allows upto 132 characters in a line.
    Choose shorter var names then it should fit. :wink:
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • DenSterDenSter Member Posts: 8,307
    riiight, and then have 5 more comment lines to explain what the variable names mean :roll:
  • eromeineromein Member Posts: 589
    You are joking now.... I know.... But I've seen databases with just this kind of crap.... seriously!

    Variable names like T_SH for SalesHeader and T_C for Cust.

    And just to make you all understand how bad this is.... here's a popquize:


    What is the subtype of the variable T_IJ?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Timo_LässerTimo_Lässer Member Posts: 481
    eromein wrote:
    [...]
    What is the subtype of the variable T_IJ?
    Inventory Journal :?: :!: :idea:
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • DenSterDenSter Member Posts: 8,307
    Absolutely, I'd rather read through 10 lines of code with clear names than trying to figure out what the variable names mean. :shock:
Sign In or Register to comment.