Indicators in depth
<< Back
Let's quickly go over what Indicators are in VDF.
- They are a special type of "Boolean".
- The scope is always global, even if you define them inside a procedure.
- To define an indicator, you would usually use the command "Indicator".
- To change the value of an indicator, you have to use the command "Indicate" or "Ind".
- The "Indicate" command can also define an indicator if you haven't defined it already. (Super dangerous)
- The "Ind" command force you to define the indicator before you can use it. Therefore, don't use the command "Indicate"
- Some common built-in indicators are Err, FindErr, Found, SeqEof, SeqEol, and MultiUser.
- A full list of built-in indicators can be found inside FMAC.
Let's dive under the hood.
- Each indicator (doesn't matter it's built-in or user-defined) is represented by a number. For example, Err is 127, Found is 254. So on so forth.
- The first user-defined indicator starts at the number 13.
- You don't have to address an indicator by name. "Indicate |254 True" is the same as "Indicate Found True".
- You can have nameless indicator. You don't have to define them, you just use them. "Indicate |199 True" is your nameless indicator (with the number 199 associated with it)
- Take a look at cReport.pkg, line 961 in DataFlex 20 Alpha 2.
- In the Console Mode (CM) days (before VDF), there were no boolean type. Programmers were using indicators as booleans.
- If you are working with an old VDF application which it contains legacy CM code, the following is worth paying attention to.
Chances are that the legacy CM code will use indicators.
- If you define too many indicators in your program, you can "overlap" the built-in indicators.
The accidential overlapping indicator is truly scary. The "Err" indicator is defined as 127. The very first user-defined indicator starts at 13.
If you have 115 indicators, the 115th indicator will basically be the Err indicator. The compiler is not going to warn you about it.
Indicator x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20
Indicator x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40
Indicator x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60
Indicator x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75 x76 x77 x78 x79 x80
Indicator x81 x82 x83 x84 x85 x86 x87 x88 x89 x90 x91 x92 x93 x94 x95 x96 x97 x98 x99 x100
Indicator x101 x102 x103 x104 x105 x106 x107 x108 x109 x110 x111 x112 x113 x114 x115
Showln "115 - " (x115) // False
Indicate Err True
Showln "115 - " (x115) // True
Indicate Err False
Showln "115 - " (x115) // False
Indicate x115 True
Showln "Err - " (Err) // True
Indicate x115 False
Showln "Err - " (Err) // False
Indicate x115 True
Showln "Err - " (Err) // True
InKey FieldIndex
If you change the value of "Err", you change the value of "x115" because both indicators both represent the number 127.
The above sample is fully compilable. I encourage to try it out.