Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

How assign array value to normal variable?

Posted on by Microsoft Employee

Hi,

I have a small issue fromdate is array variable and I have a code below

DateG := fromdate[1];

Here DateG is global variable with date data type and I am assgining fromdate value to datrg but I got an error you cannot := this for normal variable you have to assign to dimension variable only.

Why this type of error came i can't assign this fromdate array variable to normal date variable.

And I have used this fromdate [1] as function parameter it worked.

Why can't I assign to normal date variable.

One more thing fromdate is also date data type but it's an array.

Please any one suggest me.

Thank you

Ramesh

*This post is locked for comments

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: How assign array value to normal variable?

    Please check variable column No.

    try to use without spaces and .

  • ManishS Profile Picture
    ManishS 6,578 on at
    RE: How assign array value to normal variable?

    Are you sure you are getting error at this line DateG := fromdate[1];

    Can you share the screen shot of the code.

  • mmv Profile Picture
    mmv 11,465 on at
    RE: How assign array value to normal variable?

    it still works:

    vDateArray[1] := 010117D;

    vDateArray[2] := 010217D;

    vDateArray[3] := 010317D;

    FOR lvCount := 1 TO 3 DO BEGIN

     vFromDate := vDateArray[lvCount];

     MESSAGE('%1',vFromDate);

    END;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How assign array value to normal variable?

    One more thing I got this error in for loop means my code is like below

    DateG := fromdate[column No.];

    When I compile i got an error you cannot assign array variable to normal variable.

    Thank you

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How assign array value to normal variable?

    Hi Mohana,

    I am getting at compile time.

    Thank you

  • mmv Profile Picture
    mmv 11,465 on at
    RE: How assign array value to normal variable?

    Hi,

    There's no issue in assigning the array variable value to a normal variable of the same type.  It works well.

    3386.ImportLicense.jpg

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: How assign array value to normal variable?

    Are you getting error at run time or compile time?

    I tried this and working fine

    arraytest[1] := 010120D;

    testdate := arraytest[1];

    MESSAGE('%1',testdate);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans