Submitted by gregory on 2015/04/05 04:52
The documentation of smart fields in the user manual is inadequate and difficult to understand. I would like to improve it – but I cannot sufficiently understand the topic to be able to do so. In addition, some examples do not work as expected.
 

Currently, there is no UI specific to creating these smart folder-type fields, but users can easily modify existing examples:

ItemIsBold:
Type: Yes/No

Options: <source>SELECT ItemID, [ItemID]>0 AS ItemIsBold

FROM ¯qItemFont

WHERE ((InStr([ItemFont],"|B|")<>0));

</source>

*** This used to work, but no longer works now ***

Figure 1 ItemIsBold definition
 
Figure 2 Two items in bold are not reported as being bold

At point 1, we see two items the font of which is in bold. At point 2, we see that there are apparently no items in bold anywhere in the IQbase. Perhaps the way in which the bold type style is stored has changed?

In the next example, we are looking for data that contains the word "Somiro":

ProjectSomiro:
Type: Yes/No

Options: <source>SELECT ItemID, [ItemID]>0 AS ProjectSomiro

FROM ¯qItem

WHERE ((InStr([Item],"{Somiro}")<>0));

</source>

*** This does not work (although I am fairly sure that it used to do so). If you create a grid based on the field ProjectSomiro, it appears to be empty. I have run this example in an IQbase based on the sample data.

Figure 3 Definition of the field Project Somiro
 

Figure 4 Display of a grid based on the field Project Somiro

Interrogating system data in InfoQube

InfoQube functions, in part, because it incorporates what is effectively an active data dictionary. What this means is that the operation of the product depends upon system data which can be accessed by the IQ user by means of SQL queries.

In this example, I have created an SQL query and used it in a grid in which I wish to make a list of all the field names currently in use in a particular IQbase.

Figure 5 shows how I have constructed the necessary SQL statement. Note that it is not clear to me why it is necessary to include an ID field in the query string. I assume that this is necessary because when creating a grid, it is necessary to tie together the field values from different fields. Unfortunately, the documentation on smart fields is silent on this issue. I would like to be able to improve it, but cannot do so without assistance from Pierre.

Figure 5 Building up the necessary SQL in an Excel spreadsheet

Figure 6 shows how I have used the SQL string in the definition of a field called FieldName:

 

Figure 6 Defining the field in the IQbase Field Properties

 

Figure 7 shows what happens when a grid is created based on this field. Only one row is returned. The IDitem appears to correspond to a single new item which however does not appear in a grid based on item.

 

Figure 7 Result: only one row which contains no useful information

Just to prove that smart fields can be made to work, let’s examine this case. I want a list of items which include the word “Gregory” in the text. (Yes, I know there are easier ways of achieving this, but I am just trying to illustrate a point here…).

Figure 8 Definition of the field Gregory

Note that I have unintelligently based this example on one of the examples that Pierre gives in the standard documentation for the product. Therefore I do not know why it is necessary to include itemID, much less [itemID]>0 - which will always return true, I think. If I now create an eponymous grid (that is to say, a grid with the same name as the field), I get fairly intelligent results (Figure 9):

Figure 9 Results of using the smart field Gregory

 The source of this field, that is to say, the data upon which it is based, is a system query called ¯qItem. This is the way in which the InfoQube product actually implements fields; for each field there is a system query whose name is the name of the field preceded by the characters “¯q”. Thus in this case the query is called “¯qItem”.

The examples given by Pierre in the system documentation frequently use underlying InfoQube system data, indicated by the use of the  macron character, "¯", Windows key alt +0175. It is unclear to me when it is necessary or advantageous to use system data in this way since it is frequently possible simply to use the name of the field exactly as it normally appears in InfoQube. However, that is not always the case – my earlier example of obtaining a list of field names is an example of where it is essential to use this underlying system data.

 

Comments

You're smarter than me.
Mark, Can you quickly summarize the main point(s) of your post ? I'm not sure what you're aiming for.
 
-------------------------------------------------------
Windows 8.1
Sony Vaio S Series 13 (SVS131E21L)
Ram:8gb, CPU: Intel i5-3230M, 2.6ghz

gregory

2015/04/08 16:04

In reply to by Armando

My main point is that the documentation of system data is wholly inadequate to permit its programmatic interrogation. I have spent days of work spread over months of frustration trying to get examples such as those that I supply to work. To get anything at all to work, I have had to use Microsoft Access to examine the database underlying an IQbase and experiment extensively with that. Some examples that I have tried then work perfectly in InfoQube; some do not.
 
To explain what I'm trying to achieve is possible but not within the confines of forum posts. To document what I am trying to achieve will take many more hours of effort, which I will undertake tomorrow. I hope it will prove to be worthwhile. I chose two of the examples I have documented because they are very close to the ones shown in the manual. The Project Somiro example used to work, I think, and no longer does so. The example of interrogating field names is important to me because I wish to document in InfoQube the process of designing and building an IQbase. That will, I hope, be useful to others who follow.
 
Mark GREGORY, Redon, France - GMT +1/+2; EST +6

gregory

2015/04/22 06:58

In reply to by Armando

The main point of my original post is that the documentation of this feature is so poor that it is extremely difficult to know how to do even relatively simple things. In particular, in some of the examples use is made of underlying InfoQube system "tables" (actually, in most cases, queries); in others, use is made of user-level fields. By the latter, I mean the fields with which we are normally familiar when we use InfoQube. Generally speaking, the distinction is that the former start with a macron character ("overline"); the latter are just ordinary InfoQube field names. The existing documentation gives no guidance as to when it is necessary to have resort to the underlying InfoQube system data nor how to use it.

Here is an example which uses only user-level InfoQube fields which I would have thought would work properly but does not. It is based on an existing query which works well. The only change that I have made to the query is to try to refer to another field in the same grid so as to subset the amount of data returned by the SQL SELECT statement. I have tried using a  Yes/No (boolean) field called IsCurrent. In the example shown, I am using a text field Current which can take the value Y or N. Adding 'AND IsCurrent' or - as here - 'AND (current = 'Y')' causes the query to break in the way shown in figure 1.

 
Figure 1 Error message
 
So, to go back to the original question: what can be done to make the documentation of this feature actually usable? There does not appear to be much enthusiasm for the suggestion that I have put forward for hangouts. Recall that the reason that I suggested hangouts was that by this means we would be able to gather to work together - e.g. towards improved system documentation in areas such as this. I still think that is a good idea.
 
Q1: Who, apart from David_H, Pierre and I, thinks that this would be a good idea?

However, for now, it seems probable that the only way forward is for me to ask specific questions on this forum for every question that I have.

Q2: Therefore, the specific question is: why does the example shown not work? How can it be made to work?

Q3: More generally, when is it necessary to have resort to underlying system data and when is it okay to use InfoQube user-level fields?

Q4: Most generally, how does InfoQube work internally? When is it safe and necessary to use underlying system data?
 
<edit> The reference to a grid 'current' is unnecessary - the field current is part of the grid Kind. However, removing it, such that the SQL string reads:
 
select kind as KindVal from Kind  where ((InStr(kind,'\') >0) and (current = 'Y')) order by left(kind,255)  asc
 
does not change the result.
 
Figure 2 shows the grid:
 

Figure 2 The grid Kind
</edit>
 
Mark GREGORY, Redon, France - GMT +1/+2; EST +6

Pierre_Admin

2015/04/22 12:15

In reply to by gregory

Hi Mark,
 
The best way to debug your application is for you to create a sample IQBase and put it in a shared Dropbox folder. This way I'll be able to debug it.
At first sight however :
  1. Your SQL query renames Kind as KindVal, but this is already a field name in the Kind grid. 
  2. Also the Instr(Kind,"\")>0 does nothing since all values of Kind have a "\". What are you trying to achieve ?
 
Pierre
 

gregory

2015/04/24 01:54

In reply to by Pierre_Admin

Hello Pierre.

I shall share the IQbase in question with you when I have cleaned it up a little bit! Thank you very much for the kind offer to debug it.

My SQL query does not rename kind as KindVal. KindVal is a drop-down list and is the field which I normally use in grids.  I cannot change values in KindVal because I have 'entry must be in list' set for that field. Kind is where I store the data on which the drop-down is based. I have to be able to keep that data up-to-date, and I do that by changing values in the Kind field.

As it happens, you are correct that all values of Kind have a "\" within them. I used the example to show that a complex piece of SQL works. Adding a simple condition, "current = 'Y'", causes it to stop working. In fact, as the following example shows, it seems to be that particular simple condition that causes the SQL to break. What I am trying to achieve with the use of a current field is to restrict the number of values which appear in the drop-down list, which is currently 405 - too high for everyday use.
 
This is a simple condition failing:
 


This brings me back to my original question Q3, which is, what are the rules which govern what is and is not acceptable as an SQL statement? This is what needs to be documented, and perhaps bug-fixed, if this functionality is not to remain something that always requires your specific attention.
 
Mark GREGORY, Redon, France - GMT +1/+2; EST +6

Pierre_Admin

2015/04/24 09:14

In reply to by gregory

[quote=gregory]
My SQL query does not rename kind as KindVal.
 

[/quote]
 
"select kind as KindVal" : This means, read the values of field "kind" and rename it "KindVal" !!!
 

gregory

2015/04/30 11:27

In reply to by Pierre_Admin

As I said in the title of this post, it is quite possible that it is me that is being very stupid. To me, the use of the alias KindVal gives a name to that subset of kind values which meets the WHERE clause.

 

In use, the semantics associated with the use of this name, KindVal, are very different from those of Kind.

 

If I click on Kind: I can change values of Kind.

 

If I click on KindVal: I see a drop-down list from which I can select a value which then stays with the item to which I apply it.

 

Thus in my original screenshot, there are many items each labelled as '\meta\kind\'. '\meta\kind\' is a class name. An item in the grid Kind can have only one value for KindVal. Thus it is either a '\bird\' or it is a '\plane\' or it is '\Superman\' - but it can only be one of the three.

 

Mark GREGORY, Redon, France - GMT +1/+2; EST +6

Also, ItemIsBold field works here...
 
Keep in mind, this field is looking at item font, not at embedded HTML codes.
An item can be bold because you've set it's item font or by enclosing the text with <b></b> (easier to do now with the WYSIWYG and Popup editors)
 

gregory

2015/04/08 16:09

In reply to by Pierre_Admin

I hinted at that in my original post - I suppose that the WYSIWYG editor does things differently from the old ways of storing typeface information. This only serves to emphasise that the gap between the product and its documentation continues to increase. Doing almost anything in InfoQube requires not only looking at the manual but also searching through a significant number of forum posts.To take a straightforward example, the WYSIWYG editor is hardly documented at all. I am not convinced that every user will wish to search hard for information as to how to do things.
 
Mark GREGORY, Redon, France - GMT +1/+2; EST +6

Pierre_Admin

2015/04/08 16:12

In reply to by gregory

True... and you're proposing that I ... ?

gregory

2015/05/12 16:15

In reply to by gregory

It is possible to get smart fields to work well, and this is a considerable strength of the InfoQube product.

I have no doubt that the way I have done this is not optimal, but I put it forward as an illustration of what is possible. I have created a field DuplicateItem. In the options for the field I have included:

<source>SELECT ItemID, ItemID > 0, Left([¯fText].[Value],255) AS DuplicateItem
FROM ¯fText
WHERE (((Left([¯fText].[Value],255)) In (SELECT left([¯fText].Value,255) AS DuplicateItem
FROM ¯fText
WHERE ((([¯fText].FieldID)=1))
GROUP BY [¯fText].Value
HAVING (((Count(*))>1))
)))
ORDER BY Left([¯fText].[Value],255);
</source>
 
This SQL select statement itself contains a nested select query. The nested select query finds items having duplicate values. The outer select returns three terms. The first two appear to be required and are probably necessary to inform InfoQube of the actual unique tuple identifiers of duplicate items. As I have said before, it is not clear why the syntax is as it is and I continue to urge that that syntax be documented. The third term returns the actual text value of the duplicate item.

I then create an eponymous grid which displays the duplicated items:
 


For information, I need something like this because my application forbids the creation of duplicate items – items containing the same value. At the present time, InfoQube does not include desirable facilities to set integrity constraints for fields. I would suggest that the product would be much stronger if it were possible to set field-level constraints such as no-duplicates and lookup. Lookup would require the user of a detail field to select a value that already exists in a master field. I suspect that the introduction of this functionality would be fairly straightforward given the way that the product is based upon the use of a relational database.
 
NB: This post is now rather difficult to understand given that all the illustrations which I previously put into it – at considerable expense in time and effort – have been removed or are otherwise no longer present. Should I make the time to put them back?
 
Mark GREGORY, Redon, France - GMT +1/+2; EST +6