tips:revmedia:v4i8a1

Descripter - Larry Coon

Published ByDateVersionKnowledge LevelKeywords
Sprezzatura Ltd01 JAN 19933.01+EXPERTDESCRIPTER

There is a little used system function called Descripter() which can be used to obtain information about the internal format of a variable. Most people will only have come across Descripter in the context of determining whether a variable is unassigned, namely

  DescInfo = Descripter(Var)
  If DescInfo[-2,2] = Char(245) : Char(255) Then
    Unassigned = 1
  End Else
    Unassigned = 0
  End

but it can be used to find out much more.

The Descripter function, when passed a variable, returns 10 bytes describing the variable. As it is an internal R/Basic function it does not need to be declared. Bytes 9 and 10 describe the variable. The remaining bytes vary according to the type of variable.

Byte 10  ³ Byte 9    ³ Description            ³ Bytes*
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ FF        ³ String of length 0     ³
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ FE        ³ String of length 1     ³ 1 = String
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ FD        ³ String of length 2     ³ 1-2 = String
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ FC        ³ String of length 3     ³ 1-3 = String
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ FB        ³ String of length 4     ³ 1-4 = String
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ FA        ³ String of length 5     ³ 1-5 = String
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F9        ³ String of length 6     ³ 1-6 = String
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F8        ³ String of length 7     ³ 1-7 = String
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F7        ³ String of length 8     ³ 1-8 = String
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F6        ³ Pointer**              ³ 1-2 = Offset
         ³           ³                        ³ 3-4 = Segment
         ³           ³                        ³ 5-6 = Length
         ³           ³                        ³ 7-8 = Overhead for growth
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F5        ³ Unassigned variable    ³
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F4        ³ Array                  ³ 5-6 = 1st dimension
         ³           ³                        ³ 7-8 = 2nd dimension
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F3        ³ Literal string > 8 byte³ 1-2 = Offset
         ³           ³                        ³ 3-4 = Segment
         ³           ³                        ³ 5-6 = Length
         ³           ³                        ³ 7-8 = Overhead for growth
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F2        ³ String > 8 bytes       ³ 1-2 = Offset
         ³           ³                        ³ 3-4 = Segment
         ³           ³                        ³ 5-6 = Length
         ³           ³                        ³ 7-8 = Overhead for growth
ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
FF       ³ F1        ³ Integer 0-32767        ³ 1-2 = Integer
ÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

    *    When two bytes are listed, result = lower byte * 256 + upper byte
    **   The descripter of the variable in the calling program is appended
         to the descripter for the pointer

(Volume 4, Issue 8, Page 4)

  • tips/revmedia/v4i8a1.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1