Re: [development-axapta] Can anybody explain me this syntax

2005-07-27 Thread Sonny Wibawa Adi




Hi, Thomas,


It's like a property in C#.

Here is the code in C# with the same function as the
method in Axapta (which in Axapta, it's called an
'accessor method').

public string name
{
  get
  {
    return _emp.name;
  }
  set
  {
    _emp.name  = value;
  }
}

About the parameter syntax: _Type n [= defValue].
The meaning of [= defValue] is the default value if
the parameter is not set.
So, in C# you can access the property value by calling
the property name like this:

MessageBox.Show(MyObject.name);

In Axapta, you just doing the code like this:

box::info(MyObject.name());

Axapta will set n as the same with _emp.name (in the
argument), so The line code _emp.name = n; will have
no effect to _emp.name (i.e. set _empl.name into n,
which has been set equal to _empl.name).

When you want to set the property value in C#, then it
simply like this:

MyObject.name = "My Name";

In Axapta, this is how we set from the accessor
method:

MyObject.name('My Name');

This will change _empl.name into a new value n in this
line code _emp.name = n;. The returned value is not
processed and the compiler will not give a syntax
error.

In Java, it's like the same with getProperty and
setProperty methods. The difference between Java's set
and get methods with Axapta's accessor method is,
Axapta write the code in only one method using a
default value parameter.

Welcome to OOP in Axapta using X++. :)



Regards,


Sonny Wibawa Adi, MBSCP, MCAD.NET, MCSD.NET, MCP


--- Thomas <[EMAIL PROTECTED]> wrote:

> Hello,
> I am used to programming Java and C#. But for some
> reason I have 
> problems understanding this syntax:
> 
> EmplName name(EmplName n = _emp.name)
> {
> _emp.name = n;
> return n;
> }
> 
> I understand the following:
> the method name returns an EmplName. when calling
> the method you do it 
> with a parameter n of the type EmplName. But what
> dows the n = 
> _emp.name do? and what goes on in the method body?
> 
> 
> 
> 
> 
> 



    

Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 





  




  
  
  YAHOO! GROUPS LINKS



   Visit your group "development-axapta" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









Re: [development-axapta] Can anybody explain me this syntax

2005-07-27 Thread Harry (Harshawardhan Deshpande




hi
 
This reminds me of an incident 2 years back. My CEO decide to indulge in x++ programming (he is functional) and  the first method he had a look was something like the one that you have mentioned. After spending 30 minutes he said this does not make sense, it is as if this method is saying "Hello, I am me"    *lol*
 
anyway to answer your question
 
EmplName[1] name[2](EmplName n = _emp.name)[3]
{
    _emp.name = n; [4]
    return n; [5]
}

[1] returning value is of type EmplName
[2] name of the method
[3] if this value is not provided while calling the method the assign this the value _emp.name 
[4] assign the value of n to _emp.name
[5] return the value of n.
 
Typically while instantiating a class you would call class.name("Harry"). This will set the value of _emp.name to "Harry". Next time you want to use this value you just call class.name() this will return the value "Harry". So basically you use the same method to set the value and retrive the value.
 
Please also note that as per latest best practices "_" is reserved for variables that are being passed as parameters. so your method declaration would be 
 
EmplName name(EmplName _emplName = emp.name)
 
 
regards
 
harry



Thomas <[EMAIL PROTECTED]> wrote:
Hello,
I am used to programming Java and C#. But for some reason I have 
problems understanding this syntax:

EmplName name(EmplName n = _emp.name)
{
    _emp.name = n;
    return n;
}

I understand the following:
the method name returns an EmplName. when calling the method you do it 
with a parameter n of the type EmplName. But what dows the n = 
_emp.name do? and what goes on in the method body?







SPONSORED LINKS 
Computer part Programming languages Microsoft axapta Support exchange 

-
YAHOO! GROUPS LINKS 


    Visit your group "development-axapta" on the web.
  
    To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED]
  
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


-



    
-
 Start your day with Yahoo! - make it your home page 

[Non-text portions of this message have been removed]






  




  
  
  YAHOO! GROUPS LINKS



   Visit your group "development-axapta" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









RE: [development-axapta] Can anybody explain me this syntax

2005-07-27 Thread Oliver Mestdagh




I believe when the method is called, if you supply the EmplName parameter with a null value,
then n gets set to the value of _emp.name.
_emp.name would have been defined in an outer scope.
 
The method essentialy would be used to get or set the EmplName.
 
ie. name("Thomas) would return "Thomas"
    once the above was called,
    name() would also return "Thomas"
 
 
I believe...

-Original Message-
From: development-axapta@yahoogroups.com [mailto:[EMAIL PROTECTED] Behalf Of Thomas
Sent: Tuesday, 26 July 2005 11:09 PM
To: development-axapta@yahoogroups.com
Subject: [development-axapta] Can anybody explain me this syntax


Hello,
I am used to programming Java and C#. But for some reason I have 
problems understanding this syntax:

EmplName name(EmplName n = _emp.name)
{
    _emp.name = n;
    return n;
}

I understand the following:
the method name returns an EmplName. when calling the method you do it 
with a parameter n of the type EmplName. But what dows the n = 
_emp.name do? and what goes on in the method body?








SPONSORED LINKS 
Computer   part   Programming   languages   Microsoft   axapta   
Support   exchange   

  _  

YAHOO! GROUPS LINKS 


  
*   Visit your group " development-axapta  " on the web.
  

*   To unsubscribe from this group, send an email to:
  [EMAIL PROTECTED]  
  

*   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service  . 


  _  




[Non-text portions of this message have been removed]









  
  
SPONSORED LINKS
  
  
  

Computer part
  
  
Programming languages
  
  
Microsoft axapta
  
  


Support exchange
  

   
  







  
  
  YAHOO! GROUPS LINKS



   Visit your group "development-axapta" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.