Log In    |    Knowledge Base    |    4D Home
Tech Tip: Resetting 4D data types
Published On: April 1, 1998

If you want to reset a number to its default value, you just set it to zero (MyNumber:=0). You reset a string to the null string (MyString:=""). Simple data types are easy to reset, but some 4D data types need to be reset in less-obvious ways. Here are some examples: Pointers It is sometimes useful to know whether a pointer is in use or not (with Nil(myPointer) or with the RESOLVE POINTER command). But once you've used a pointer by pointing it at something, how do you make it nil again? The best way is to create a pointer that never points at anything, like this: C_POINTER(<>NilPointer) <>NilPointer is always nil, and can be used to clear other pointers: MyPointer := <>NilPointer Arrays Arrays can take up a great deal of room in memory, and it's good to tidy them up when you're finished with them. You can shrink an array by redimensioning it to zero elements: ARRAY LONGINT(MyLongIntArray;0) BLOBs BLOBs can be very large, but the default BLOB is an empty BLOB. You can empty yours by setting its size to zero: SET BLOB SIZE(MyBLOB;0) Pictures Pictures can also take up lots of memory. You can use the syntax MyPicture. * MyRatio to resize a picture. If MyRatio is greater than one, MyPicture gets bigger. If MyRatio is less than one, MyPicture gets smaller. If MyRatio is zero, MyPicture's size becomes zero: MyPicture: = MyPicture * 0