Forums

Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum $label trouble

  • $label trouble

    Posted by Mischa on January 10, 2024 at 11:25 pm

    Since Omnis 10.???? introduced the $label property, I’m experiencing inconsistent problems with my own $label property, that I’m using since many years. My $label definition is a default property in every table class, that returns a compacted string like ‘John Doe, born 3. Feb. 1968‘ for persons or ‘Baker Street 225a, London‘ for addresses for the specific row variable – extremely handy when used in lists, tree lists and so on.

    As you can see in the attached screen shots, $label sometimes works, and sometimes not, and I can’t find out what causes this erratic behavior. The lists and rows are filled correct, as the fields under the lists demonstrate.

    thanks
    Mischa

    Andreas Pfeiffer replied 3 months, 1 week ago 2 Members · 9 Replies
  • 9 Replies
  • Andreas Pfeiffer

    Administrator
    January 11, 2024 at 9:51 am

    Hi Mischa,

    This is hard to say without having an idea what your code looks like.

    I can only guess that there might be some characters where Omnis is having trouble with?

    Best,

    Andreas

  • Mischa

    Member
    January 11, 2024 at 11:12 pm

    Hi Andreas,

    thank you for your reply. This is the code behind the complex grids:

    Calculate mLine as iAddrList.$line ## preserve selected line
    Do iAddrList.$sendall(mIconRef.[$sendallref.$line].$text.$assign(style(kEscBmp,iAddrList.$iconid+k32x32)))

    Do iAddrList.$sendall(mLabelRef.[$sendallref.$line].$text.$assign(iAddrList.$label(2)))

    Calculate iAddrList.$line as mLine

    So nothing special mIconRef and mLabelRef refer to the two bobjs text fields in the complex grid. iAddrList is the list that holds the data – addresses in this case. Its definition is tAddresses, the table class. The code works for the icon, but not (always) for the text, that is calculated in the custom $label of the table class property. Doing exactly the same in a remote form works, as you can see in the attached image. Unfortunately, the remote form has limitations like not being able to hi-lite the selected line or displaying wanted line breaks in the text, rendering complex grids widely unusable for remote forms.

    The code for $label in the table classes looks pretty unspectacular:

    Switch pType


    Case 1 ## one liner

    Calculate mLabel as con($cinst.Street,pick($cinst.Street>'','',', '),$cinst.PCode,' ',$cinst.City,', ',cCountryObj.$countryfullname($cinst.Country)


    Case 2 ## two liner

    Calculate mLabel as con($cinst.Street,pick($cinst.Street>'','',', '),chr(13),cCountryObj.$countrycept($cinst.Country),'-',$cinst.PCode,' ',$cinst.City)


    Default ## three liner

    Calculate mLabel as con($cinst.Street,pick($cinst.Street>'','',chr(13)),$cinst.PCode,' ',$cinst.City,chr(13),cCountryObj.$countryfullname($cinst.Country))


    End Switch

    Quit method mLabel

    The code in the $redraw method of the window class simply is

    Calculate $cinst.$title as iRow.$label

    Let me emphasize that everything used to work fine in OS versions prior to 10 (images 2 and 3 show the examples in OS 8.1), and also in OS 11 it does not work anymore.

    My primary suspects are the new method editor and/or the conversion that break the code.

    thanks
    Mischa

  • Andreas Pfeiffer

    Administrator
    January 12, 2024 at 8:12 am

    Hi Mischa,

    I am still not sure what you are trying to achieve here. Would you mind sending a test case to the Omnis support so it can be investigated and if there is a fault they will raise it to Engineers.

    Best,

    Andreas

  • Mischa

    Member
    January 13, 2024 at 1:40 am

    Hi Andreas,

    thank you for your reply. It appears to be a conversion problem. When I copy the method lines and then completely delete the $label method in the table class, recreate the method $label again and paste the code into it, all local and parameter variables are not resolved by the code editor (they appear as black text) and must be defined manually again. After this, $label works as expected again.

    I have another case, where a local variable is defined as schema class subtype in the definition table, but myRow.$statementobject.$prepare() causes an unknown property error, although the row is shown as not empty and its definition matches the schema class.

    I have to insert a Do myRow.$definefromsqlclass(‘sSchema’) at the start of the method, then it works.

    So it seems that local variables are not always converted correct, and it’s very hard to see, when and why the conversion fails, since I’m doing a subtype definition of local rows and lists all over the library and they appear to work without a problem as far as I have tested yet.

    So what I can offer is to send the whole library since the occurrence of the problem is not predictable.

    best greetings and thanks

    Mischa

  • Andreas Pfeiffer

    Administrator
    January 15, 2024 at 10:43 am

    Hi Mischa,

    I am not sure what you are trying to achieve using the $prepare of a row variable when using a schema.

    Actually my recommendation always using a table class rather a schema class directly. If doing so there are two ways to use a table class:

    1. The table class has an attached schema class in its $sqlclassname property. If so that table class is best use for a row variable where you would typically use its $select, $fetch, $update, $insert etc. methods to manipulate one specific record.
    2. The table class has no schema class involved. In this case you would typically have a statement block and then using $cinst.$statementobject().$prepare() to execute the statement block. The result set then determines the columns of the current instance which would be typically a list variable to represent a number of records.

    I hope this helps.

    Best,

    Andreas

  • Mischa

    Member
    January 16, 2024 at 10:10 am

    Hi Andreas,

    thank you for your reply.

    I am not sure what you are trying to achieve using the $prepare of a row variable when using a schema

    Seems that it is required to prepare the statement object before you launch an SQL statement?

    The problem however is, that the subtype of the row variable definition is ignored, regardless whether you use a schema or table class – please see picture one.

    Another strange example is that a parameter, although populated correct, is not trapped in the switch statement – please see picture two. pType is an integer 255.

    From my perspective, there is a conversion problem with $label and/or the new method editor. When a new property is introduced, it must not break the existing code, when a developer has used the same property name before. That should be a no go for every development platform.

    thanks
    Mischa

  • Andreas Pfeiffer

    Administrator
    January 16, 2024 at 11:48 am

    Micha,

    Again this is hard to say without having the library. Would you mind sending me a small sample library that demonstrates the problem?

    Thanks and best regards,

    Andreas

  • Mischa

    Member
    January 17, 2024 at 1:37 am

    Hi Andreas,

    I’ve put a sample library together, actually all classes necessary to demonstrate the conversion problem are dragged from my library into sample.lbs. It seems, that converting less classes has an effect, because now not all problems I’ve reported here come up for whatever reason.

    sample.lbs is a OS 10.1 library. Please run it with 10.1 first just to check that it works (Windows 10, have not tested on a Mac). After opening the library, please open folder Persons and open window PersonsSQL. Hit pane ‘Angehörige’ and enter ‘klement’ into the search field. The window now should look like in the upper half of the image below.

    Now open the library with Studio 11 (latest version) and do the same. As you should see, the window title is missing, also the persons in the search list have no label anymore.

    The window title is generated in the $redraw method of PersonsSQL with

    Calculate $cwind.$title as iRow.$label(1)

    where iRow is a subtype of the table class tClients.

    The labels of the persons in the tree list are generated in the same way in the window class widTreeList with

    Do iTreeRef.$setrootnode(iRootRow.$iconid,iRootRow.$label(1),iRootRow.UID,iRootRow.$dataclass,iRootRow,kTrue)

    You can download the sample here, it includes a sample SQLite db, please put it into the same folder as the library.

    http://www.microartwork.com/Products/sample.zip

    best greetings and thanks
    Mischa

    • Andreas Pfeiffer

      Administrator
      January 17, 2024 at 8:11 am

      Hi Mischa,

      If this turns out to be a conversion problem I would like to recommend that you present this to the local Omnis support team. I think handling this here might be too specific for the public forum.

      Best regards,

      Andreas

Log in to reply.