'CLEAR' statement

Roelof
Member Posts: 377
Maybe a stupid question but might have a big impact if you don't know the result:
What happens with the internal variables of a record if it is called from another object and you do a Clear(rec)? For example:
- SalesLine.Setvar1(True);
- Clear(SalesLine);
Is 'Var1' in the SalesLine record object cleared or is it still set as 'True'?
What happens with the internal variables of a record if it is called from another object and you do a Clear(rec)? For example:
- SalesLine.Setvar1(True);
- Clear(SalesLine);
Is 'Var1' in the SalesLine record object cleared or is it still set as 'True'?
Roelof de Jonghttp://www.wye.com
0
Comments
-
Why don't you type it out and find the answer? It doesn't sound that hard to write the code for it, and you did it right there in the post. Should take all of 5 minutes to write it up and find out. :-k0
-
-
Roelof wrote:Maybe a stupid question but might have a big impact if you don't know the result:
What happens with the internal variables of a record if it is called from another object and you do a Clear(rec)? For example:
- SalesLine.Setvar1(True);
- Clear(SalesLine);
Is 'Var1' in the SalesLine record object cleared or is it still set as 'True'?
The answer, as many question are, is "It depends". But in general, the record object is cleared, and all values are cleared.
If you look at all values in the Salesline record object immediately after the CLEAR statement, the values in all fields will be blanks/zeros.
BUT, if you re-read the original sales line record, Var1 will be "True" if there is a MODIFY statement in the "SetVar1" function.
However, if there is no MODIFY, then the re-read of the sales line record will result in whatever value of Var1 was prior to the "SetVar1" function. For example, If it was previously FALSE, then it will return FALSE.
Hope that helps.Ron0 -
Ron,
But I'm basically referring to non-record fields, like variables, used in the SalesLine object itself. My actual question is: are all variables, used in the object re-set too. (Don't care about the record fields).Roelof de Jonghttp://www.wye.com0 -
It will be cleared. If you just want to clear the fields then you have to use INIT. But keep in mind when you use INIT thatNAV Online Help wrote:Primary key and timestamp fields are not initialized."Money is likewise the greatest chance and the greatest scourge of mankind."0
-
Roelof wrote:Ron,
But I'm basically referring to non-record fields, like variables, used in the SalesLine object itself. My actual question is: are all variables, used in the object re-set too. (Don't care about the record fields).
So let me try to understand your question. Here's your original example:
- SalesLine.Setvar1(True);
- Clear(SalesLine);
Is 'Var1' in the SalesLine record object cleared or is it still set as 'True'?
Followup questions:
1. In your example, Var1 is a local variable within the Salesline object, but NOT a field in the Salesline record, right?
2. And, there might be additional local variables Var2 and Var3 in the Salesline object as well, right?
RonRon0 -
Ron,
Correct.
I did a small test myself and variables are being cleared correctly.Roelof de Jonghttp://www.wye.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions