How to decide the no. of '#' in progress bar?

havhav Member Posts: 299
Hi All,
I have written a codeunit which does some processing and at the same time displays the progress of processing by using a 'ProgressBar' variable of Dialog data type.
I have used following text constants
TEXT008 : Synchronising Products and Stock
TEXT009 :#1#########################\@2@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Note the total no. of '#' used in TEXT009 is 26

Here is my code to open the dialog and update '1 'in TEXT009
ProgressBar.OPEN(TEXT008 + TEXT009);
ProgressBar.UPDATE(1, StockKeepingUnit."Location Code" + ' / ' + StockKeepingUnit."Item No.");
.......

The 'StockKeepingUnit' is a record variable of 'StockKeeping Unit' table and it has following field definitions:
Item No. Code 20
Location Code Code 10

When i run the codeunit, the progress bar displays the value of '1 'as StockKeepingUnit."Location Code" + ' / ' + StockKeepingUnit."Item No." however for some records it gives me error "The length of source exceeds the size of destination buffer".

I am not sure how do we decide the no. of '#' we keep in the Text constant TEXT009.
Say if 'Location Code' assumes max 10 char's and if 'Item No.' assumes max 20-char's then does it mean that i have to keep 33 '#' char's in TEXT009
i.e. 10 for 'Location Code'
3 for ' / '
20 for 'Item No."

or is it the case that i have to keep double no. of '#' then the expected max. no. of char's to be displayed?
i.e. 33*2 = 66

Any idea?

Regards,
Hemant
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)

Answers

  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I think the number of possible characters is 1024. The number of the hash keys (#) only sets how many characters to display in the dialog window.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • havhav Member Posts: 299
    What about the error "The length of source exceeds the size of destination buffer".?
    Why is this error generated?
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • havhav Member Posts: 299
    Reminder!!!
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • havhav Member Posts: 299
    Hi,
    The error is still getting reproduced.
    hav wrote:
    TEXT008 : Synchronising Products and Stock
    TEXT009 :#1#########################\@2@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Note the total no. of '#' used in TEXT009 is 26

    Here is my code to open the dialog and update '1 'in TEXT009
    ProgressBar.OPEN(TEXT008 + TEXT009);
    ProgressBar.UPDATE(1, StockKeepingUnit."Location Code" + ' / ' + StockKeepingUnit."Item No.");
    .......
    

    I have now updated TEXT009 to total no. of '#' equal to 27 and the Update command as below:-
    ProgressBar.OPEN(TEXT008 + TEXT009);
    ProgressBar.UPDATE(1, StockKeepingUnit."Location Code" + '/' + StockKeepingUnit."Item No.");
    .......
    

    Note that i have removed spaces before and after '/' in Update command.
    I have kept total no. of '#' as 27 because in my case "Location Code" can be max. 10 char's and Item No. can be max 16 char's
    Hence 10+1+16 = 27.
    But still the error is reproduced.
    I turned on the debugger and it stops at the Update command. I noticed that this happens only when Item No. contains max 16 char's.
    For all other value less than 16 char's there is no error.
    ???

    Regards,
    Hemant
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • KYDutchieKYDutchie Member Posts: 345
    Hemant,

    Please beware that the '\' character is translated into the Linefeed and Carriage Return characters. (10+13).
    That is probably why you are getting the error. Your calculation should be 10+2+16 = 28.

    Hope this helps.

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • havhav Member Posts: 299
    Hi,
    Thanks for your reply.
    Please note that i have used a forward slash('/') and not a backward slash('\') hence there is no question for a linefeed.

    There is one thing which i pasted incorrectly.
    ProgressBar.OPEN(TEXT008 + TEXT009);
    .......
    
    My apologies.
    It is actually.
    ProgressBar.OPEN(TEXT008 + TEXT009, StockKeepingUnit."Item No.");
    .......
    

    I even doubt the Open() which opens the Progress bar displaying Item No. as max 16 char's long which later on the Update() changes to LocationCode/ItemNo
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • klavinklavin Member Posts: 117
    I just encountered this same error last week while using STRMENU. I was allowing a selection and in the top option, which was invalid I wrote something to the effect of Select an option for Item x, and the description. I don't remember the exact wording or length, but I realized it worked for some items with a shorter description, but failed on the longer. I shortened the characters showing with COPYSTR and it was resolved.

    Try testing different lengths and shortening your @ to a much smaller size, and see if it works. Also test different text lengths on a basic Dialog and see when it is overloaded.
    -Lavin
    "Profanity is the one language all programmers know best."
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I'm able to update my Window with every value I like. As I said, there might be a limitation to 1024 chars at all, but that is independent from the display length of the fields. I believe the problem is elsewhere.

    What is your NAV version and Build No.?
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • FDickschatFDickschat Member Posts: 380
    Well, even though it might be interesting to find the source for this odd behaviour, wouldn't it be easier to just increase the size of the window (if that solves the problem for you)?

    Anyway,
    - How many language captions do Text008 and Text009 have?
    - Do you have items with CR/LF in the item No.?

    Try changing the following code
    ProgressBar.OPEN(TEXT008 + TEXT009, StockKeepingUnit."Item No.");
    
    to
    ProgressBar.OPEN(TEXT008 + TEXT009);
    ProgressBar.UPDATE(1, StockKeepingUnit."Item No.");
    
    You might also try this:
    hav wrote:
    ProgressBar.UPDATE(1, StockKeepingUnit."Location Code" + ' / ' + StockKeepingUnit."Item No.");
    
    DummyTextVar := StockKeepingUnit."Location Code" + ' / ' + StockKeepingUnit."Item No.";
    ProgressBar.UPDATE(1, DummyTextVar);
    
    I don't know why it should make a difference but what the heck!


    But as einsTeIn.NET wrote:
    I'm able to update my Window with every value I like. As I said, there might be a limitation to 1024 chars at all, but that is independent from the display length of the fields. I believe the problem is elsewhere.
    Same here. Maybe it is a problem of the client. Try another NAV build.
    Frank Dickschat
    FD Consulting
  • havhav Member Posts: 299
    I doubted correctly.
    hav wrote:
    I even doubt the Open() which opens the Progress bar displaying Item No. as max 16 char's long which later on the Update() changes to LocationCode/ItemNo

    I tried changing
    ProgressBar.OPEN(TEXT008 + TEXT009, StockKeepingUnit."Item No."); 
    
    to
    ProgressBar.OPEN(TEXT008 + TEXT009);
    ProgressBar.UPDATE(1, StockKeepingUnit."Location Code" + '/' + StockKeepingUnit."Item No.");
    
    and the problem got resolved.

    FDickschat, thanks for your suggestion.

    Although the problem got fixed i couldn't realize the exact cause since everything works fine without doing the above changes if StockKeepingUnit."Item No." is < 16 char's.

    Thanks to all concerned.

    Regards,
    Hemant
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • SogSog Member Posts: 1,023
    It could be because Item No. is 20 characters long, I don't know the length of location codes, but they might be 1-2 characters long + the 3 characters for ' / ' (without the quotes), and the 16 lenght = 20 total.
    But it is good to know that when opening a dialog with a fieldvariable, it might change the buffer to that lenght.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
Sign In or Register to comment.