Date Masking - MagicCell©

ThumbNail (String Masking)

The previous 'Lookup' illustration is actually a special case of data masking where the actual data stored in the database is displayed in a different way. If your Web publishing tool has a strong capability in masking the data, you can increase the flexibility of your data presentation. Now let's look at a simple example to change the data to an image where actually, you only store the filename in the data field and you can choose either to display the filename or the images itself.

 <!--T_Magic_1.aspx-->

<script language="vb" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
   Dim MF As New Tornado.Z()
      With MF
         .dbQP = "S=1|D=car2000.mdb| Th=Title=MagicCell - Thumbnail Images"
         .dbSQL = "Select car, manufacturer, picture from carspecs "
         .dbGridMagicCell = "(;![]#|~/+{})field=picture| Macro=#picture:_tn=I=/tornado/db/images-car/~T=width=128~W=200, 200~ N=_nocar.gif#"
         .ASPdbNET()
      End With
End Sub
</script>

After you execute this example, is it what you expected like the filename is converted to an <IMG...SRC=Fielanme>? Not quite , isn't it?

The filename is converted to an <A Href..><IMG...SRC...> as a thumbnail which is linked to the original image to a popup window sized to the image. On top of that, if the image file does not exist, then a pre-arranged 'NoShow' file called nocar.gif will display instead of a broken image icon. Is that a pretty common arrangement of an image database? If you take out the shell and query code, there is actually a single property (dbGridMagicCell) to generate the entire thumbnail application and thumbnail is only one of numerous options of 'MagicCell'.

At this point of the demo, can you image that you can spend your time in designing the business rules instead of learning how to program the Web.

Now, since MagicCell © is briefly explained, return to the DataGrid illustration page (Master - Display a master grid with an embedded slave grid) example and you'll notice that the field data is transformed by MagicCell © to an embedded grid which one of the field is then linked to another drill down level of Aggregate and Charting applications.

While the application seems deep and code seems condensed and cryptic (abbreviated), however, the lines of code are few and the output quality is undeniably advanced.

Divide by Zero (Math Masking)

We'll continue with the MagicCell© illustration using a very common situation of Divide by Zero (DBZ). The following example first display the original Excel SS Named Block and then display the same block again with a calculated field of Available Budget =  (Budget - Spending) / Budget *100 while anticipating entries of 0 budget but with expense. Different DB handles this problem differently in the SQL level and I have yet to see a good solution. Tornado will handle this one for you without even touching the DB.

The masking takes place in the 3rd calculated field where it is displayed in the  percent (p) format with the formula of #Budget#-#Expense#)/#Budget# * 100. Names within the # wrappers are field names. There is a comprehensive Equation Express parser within MagicCell to enable Math operations.

 <!--T_Magic_2.aspx-->

<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)
   Dim Mydb As New Tornado.Z()
'... Module 1 display the normal Budget Data
      With Mydb
      .dbQP = "type=Excel| U=1| S=ASPdbBB| D=BudgetSS.xls| ps=-1| TextHolder=Title=MagicCell - Normal| Q=Budget| ni=none"
      .ASPdbNET()
'... Module 2 adds a calculated field of available budget % anticipating 'Divide By Zero' problem
      .dbQP = "type=Excel| U=2| S=ASPdbBB|D=BudgetSS.xls| ps=-1| TextHolder=Title=MagicCell - Divide By Zero| ni=none| nh=t"
      .dbSQL = "SELECT Dept, Budget, Expense, 'dummy' as Available From Budget"
      .dbGridMagicCell = "field=3| macro=<<(#Budget#-#Expense#)/#Budget#:p>>"
      .dbOptions="DBZ=No Budget"
      .ASPdbNET()
      End With
End Sub
</script>

Logical Masking

Another form of masking is logical masking where logical conditions are tested to determine the field's display mask. The illustration of displaying the fields in a zigzag manner is an actual application of a user. This is the most difficult example we have ever come across in our 'example chest' and if you catch the syntax of this one, you have mastered MagicCell!

<!--T_Magic_3.aspx-->

<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)
   Dim ZigZag As New Tornado.Z()
   With ZigZag
      .dbQP="U=1| S=moto| D=CAR2000.mdb|M=ty=Grid!header=false| mts=160| Th=Title=MagicCell - Logical Masking"
      .dbSQL = "SELECT Car,Price,Yr,Picture,Comment,'dummy' as Photo,'dummy' as Notes FROM CarSpecs"
      .dbGridHideFlds = "Car, Price, Yr, picture, Comment"
'... This is the ZigZag Workhorse
      .dbGridMagicCell = "(;,[]#|~/+{})Fi=Photo| Macro=(#aspdbindex#|NVL||align=right|<A HREF='/tornado/db/images-car/#Picture#'><IMG WIDTH=150 BORDER=0 VSPACE=0 HSPACE=0 SRC='/tornado/db/images-car/#Picture#' ALT='Click here to see a larger photo'></A>~#aspdbindex#|EVL|||<center><b>#Yr# #car# - #price:c#</b> </center>#Comment#), Fi=Notes| Macro=(#aspdbindex#|EVL|||<A HREF=""/tornado/db/images-car/#Picture#""><IMG WIDTH=150 BORDER=0 VSPACE=0 HSPACE=0 SRC=""/tornado/db/images-car/#Picture#"" ALT=""Click here to see a larger photo""></A>~#aspdbindex#|NVL|||<center><b>#Yr# #car# - #price:c#</b></center>#Comment#)"
      .ASPdbNET()
   End With
End Sub
</script>

Essentially the challenge is to display the fields in two columns with column 1 displaying several fields  including a Memo Field with text round off at length of 160. Round off means break the memo in the space and not in the middle of a word. The Image name field is displayed in the second column but itself linking to the original image. The twists is to toggle the display in alternate rows. Logical Mask is primary design for displaying data according to 29 pre-programmed logical conditions including text, numeric, logical, regular expression etc.... This enables you to present, hide or mask your data under different conditions.