'CLEAR' statement

RoelofRoelof 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'?
Roelof de Jonghttp://www.wye.com

Comments

  • matttraxmatttrax Member Posts: 2,309
    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. :-k
  • RoelofRoelof Member Posts: 377
    Yeah, I guess I'm lazy. But thanks for the reply. :)
    Roelof de Jonghttp://www.wye.com
  • rsaritzkyrsaritzky Member Posts: 469
    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.
    Ron
  • RoelofRoelof Member Posts: 377
    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.com
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    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 that
    Primary key and timestamp fields are not initialized.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • rsaritzkyrsaritzky Member Posts: 469
    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?

    Ron
    Ron
  • RoelofRoelof Member Posts: 377
    Ron,
    Correct.

    I did a small test myself and variables are being cleared correctly.
    Roelof de Jonghttp://www.wye.com
Sign In or Register to comment.