KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Problems compiling when assigning a Time field into a Longint array
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: May 23, 2003
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Compatibility: Version 6.8.x and 2003

When handling Time fields you may want to store their contents into arrays. As you may already know there are no arrays of type time, so you may end up using a Longint array as described in the code below:

ARRAY LONGINT(MyArray;3)
ALL RECORDS([Table 1])
 For ($i;1;Records in selection([Table 1]))
 LOAD RECORD([Table 1])
 MyArray{$i}:=[Table 1]Field2
 UNLOAD RECORD([Table 1])
 NEXT RECORD([Table 1])
End for

When running the database in interpreted mode that code will work; however it will generate an error when being compiled. The problem resides in the following assignment that assigns a time or date type value to a Longint array element:

MyArray{$i}:=[Table 1]Field2

To correct that problem, simply multiply the field value by one, which will convert its values to a longint:

MyArray{$i}:=[Table 1]Field2*1

Once that adjustment is made, the code will compile properly.