Array of records!

abartonicek
Member Posts: 162
Table: OurTable
Field name....Type
No................Code
Value............Int
...
On Card form we have:
Variable name..........DataType..Subtype.....Dimensions property
OurArrayVariable......Record.....OurTable....3
OurVariable..............Record.....OurTable.....<Undefined>
What happens with the table record that variable points to when we do this:
SETRANGE(No);
OurArrayVariable[1].Value := 20;
OurArrayVariable[2].Value := 10;
What are the values of:
OurArrayVariable[3].Value and
OurVariable.Value
Hope you know what I mean
Field name....Type
No................Code
Value............Int
...
On Card form we have:
Variable name..........DataType..Subtype.....Dimensions property
OurArrayVariable......Record.....OurTable....3
OurVariable..............Record.....OurTable.....<Undefined>
What happens with the table record that variable points to when we do this:
SETRANGE(No);
OurArrayVariable[1].Value := 20;
OurArrayVariable[2].Value := 10;
What are the values of:
OurArrayVariable[3].Value and
OurVariable.Value
Hope you know what I mean

Better to be critical then self-critical 

0
Comments
-
Whatever you do to one variable has no effect on another variable. If you do:
x := some value;
then everything else does not change.
The same happens in an array. If you do:x[i] := some value;
then x[i+n] is not affected.0 -
I know that but...
The array thing confuses me.
What if I do this:
OurVariable.Value := 50;
The field "Value" in OurTable changes it's value to 50 - Right?
But what does:
OurArrayVariable[1].Value := 25;Better to be critical then self-critical0 -
That changes the Value attribute to 25 of the element with index value 1 in your array.
Do you know what an array is?0 -
Yes!
What I don't know is the relation between that array elements and table field Value.
To put it this way:
OurVariable.Value := 50; changes the field "Value" in "OurTable"
Does
OurArrayVariable[1].Value := 25; changes anything in "OurTable"Better to be critical then self-critical0 -
The variable does not change anything in the database until you tell it to. Until then, it is just a piece of memory.
OurVariable.Value := 50; does NOT change the Value field in our table, it only changes the value of the field in your variable. To save the value to the database, you will have to do OurVariable.MODIFY.
If you do OurVariable.Value := 50; and the MODIFY, and you do OurArrayVariable[1].Value := 25 and then MODIFY you will get an error.
You should create a little test form and play around with this. It is pretty straightforward.0 -
Look at this in this way: Each Record Variable is Finger (Finger = cursor) pointing on some record in your table and the values from that record are copied on this "finger". It means - each array element is one finger, each finger can point to another record (or on same record). But each finger has own copy of the record - it is why when you change the value of one field on one "finger", others are not affected.
Record 1 - Array[1] Record 2 \ Array[2] / Array[3] Record 3 - Array[4] \Array[5]
We have 5 cursors to same table. 1 and 2 are set to record 1, 3..5 are set to record 3. If you doArray[3].Field1 := Val1; Array[5].Field1 := Val2; Array[3].Modify; Array[5].FIND('=');
In the Record 3 in field1 will be Val1. Because each Cursor is copy of the record, and the changes are transfered only with MODIFY (chages from cursor to table) or FIND and GET (read the data from table into cursor). And after the FIND the Val1 will be in Array[5].Field1 too...
etc. etc.0 -
OK
Sorry for beeing boring!
I mixed something, I was looking Form 402 and how (or why) they use arrays of records.Better to be critical then self-critical0 -
In form 402 they use arrays of record to minimize the code or something else?
They use "one dimension per tab".Better to be critical then self-critical0 -
In that form, you can see the statistics of a sales order. If you would open a sales order, turn on the debugger and hit F9, you can step through the code and see what happens. The TotalSalesLines variable does not write anything to the database, it is merely used to store statistical information. If I had designed this form, I would have created three different variables instead of an array of variables, and given them meaningful names, like TotalOrderLines, TotalInvoiceLines and TotalShippingLines or something like that.
It is nothing more than a data structure to store information that is displayed on the form.0 -
Thanx all, for your help & time!Better to be critical then self-critical0
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