Type Conversion: Code := Text

user323
Member Posts: 3
The following code is giving me an odd error -- I thought it was always possible to convert CODE to TEXT:
Type conversion is not possible because 1 of the operators contains an invalid type.
Code := Text
Any ideas?????
Report - OnPostReport() AddDimVal('SEGMENT', '2300', 'QSR', 3); AddDimVal('SEGMENT','2399','QSR Total',4); AddDimVal('END-USER-SEGMENT','2300','QSR',3); AddDimVal('END-USER-SEGMENT','2399','QSR Total',4); AddDimVal(VAR DimCode : Code[20];VAR ValCode : Code[20];VAR Name : Text[50];VAR Type : Option) DimVal.INIT; DimVal."Dimension Code" := DimCode; DimVal.Code := ValCode; DimVal.Name := Name; DimVal."Dimension Value Type" := Type; IF NOT DimVal.INSERT(TRUE) THEN MESSAGE('Dimension Value with\Dimension Code=%1\Code=%2\aready exists', DimVal."Dimension Code", DimVal.Code); CLEAR(DimVal);
Type conversion is not possible because 1 of the operators contains an invalid type.
Code := Text
Any ideas?????
0
Answers
-
I believe it's because you're passing the parameters by reference instead of value.
Since it is reference, it is expecting an actual CODE variable, and 'Text' always defaults to text. Since those values don't change inside the function, they should be passed by value instead.0 -
Ah, of course!
Thanks for the quick and correct help!0 -
matttrax wrote:I believe it's because you're passing the parameters by reference instead of value.
Since it is reference, it is expecting an actual CODE variable, and 'Text' always defaults to text. Since those values don't change inside the function, they should be passed by value instead.
Sorry could you mind to tell me how to pass by parameters and by values in C/AL.
I am reading the documentation, but there is no sample.
How am I supposed to know just from the following guide. It only explains the meaning of pass by value and reference in general programming language. I know that !! But what is the syntax in CAL.Pass By Value
Sometimes a parameter is passed to a function strictly to give the function
information. In that case, the parameter is said to be passed, or called, by value.
In this case, the parameter knows just the value of the variable or expression used
for the parameter. Since it is just a value, any change that the function does to
this parameter does not affect any variables in the calling trigger.
Pass By Reference
Other times, a parameter is passed to the function and the function modifies that
parameter. In this case, the parameter is said to be passed, or called, by reference
or by name. The parameter actually knows the variable's location in the computer
memory that it represents. The parameter passes the computer memory location
to the new function. Any changes that the function makes to this type of
parameter are permanent and affect variables in the calling trigger.
These concepts are covered more thoroughly in the next section. However, there
is one important thing to note at this point. If a parameter is passed by value, then
you can use any expression for that parameter. However, if a parameter is passed
by reference, you must use a variable for that parameter so that its value can be
changed. A variable has a location in memory, whereas an expression or a
constant does not.0 -
Answering to my own question:
VAR indicates passed by reference
(without VAR) indicates passed by VALUE..
#-o0
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