Example: School 9 ways - String vs UString - ABC & Legacy - Tps TpsW SQLite

This ZIP file has the School example done 9 ways. For Unicode you probably only will want to work with 2 of them like just TPS and TpsW.

I have updated the examples to 'Microsoft Sans Serif'. It also uses Incremental Locators for All, it was Step.

School9Ways_Bld14438_20261019_143339.ZIP (4.6 MB)

Updated ZIP to include TXA, DctX to see changes over time. New ZIP with just the EXEs and DLLs so no need to build to test (you are trusting my builds).

School9Ways_Bld14438_20261024_112532.ZIP (5.6 MB)
School9Ways_Bld14438_20261024_113240_JustEXE.ZIP (8.8 MB)

Project Folder Tpl String Notes
SchoolTps ABC Original TPS files and ABC Templates
SchoolTpsW ABC Wide TpsW files with UStrings
SchoolSQLite ABC SQLite Original Example
SchoolSqlWide ABC Wide SQLite Example changed to Ustrings
SchoolLegacyTPS Legacy CW20 School Example using Legacy
SchoolLegacyTpsW Legacy Wide Legacy + TpsW files with UStrings
SchoolLegacyUseABC Legacy Wide Legacy with Use ABC option and Ustrings
SchoolTpsC11.1 ABC Original ABC, TPS files built in C 11.1
SchoolLegacyTpsC11.1 Legacy Cw20 Legacy, TPS files built in C 11.1

It is built with 12.0.14438 and includes the CLW files so can be compared with paste and future builds. There are also C 11.1 builds to compare, currently you'll mainly see the View Position 10124 changed to 2048. (There are no INC files, I have Local Maps off.)

Example if you compare SchoolTps to SchoolTpsW you'll see the UStrings for Locators maay be treated as REAL as noted in this topic.

The original TPS files are in the TpsFiles folder and there is a BAT file to copy them to all the Sub Folders (TpsFileCopyToProjects.BAT).

All the versions that do not use TPS files (e.g. TpsW or SQLite) have an Item on the Files menu to build the new files from TPS files. A popup message will remind you:

The projects noted as Wide String have UStrings. For entering some kind of Unicode text I think Greek Wikipedia is good. Or start at the base Wikipedia page and pick a language.

Very cool Carl, I'd suggest converting this post to a wiki and move it to the Support group forum.

School 9 ways made with 14487.

School9Ways_Bld14487_20261024_154535.ZIP (5.6 MB)
School9Ways_Bld14487_20261024_155148_JustEXE.ZIP (8.9 MB)

You can compare CLWs and TXAs from the 14487 and 14438 posted above.

For the Wide TpsW projects you'll see USTRING locators get treated like STRING not REAL.

When I compare non-wide TPS projects to prior build for ABC there are almost no changes in the generated code, that's good.

For Legacy you will see Browse Locator variables generated into each procedure that were CSTRING(31) are now USTRING(31). Its done for all, it does not try to look at the Key field and see if it needs a USTRING. I think it should do that and try to not use a USTRING unless required. The Teachers and Students Browses have string locators by Name.

Some notes I made while comparing 14487 to 14438:


LibSrc changes in 14487 from 14438

Not too much new in LibSrc, just 5 files changed affecting 3 classes. Browse Entry locator may be significant with change to always

DateTime.CLW

Added .Pct() method has LEFT(CLIP()) on all RETURN as suggested


ABBrowse.INC

EntryLocatorClass CLASS(LocatorClass),TYPE,MODULE('ABBROWSE.CLW'),DLL(_ABCDllMode_)
!Shadow         CSTRING(40)    !14438 was Narrow so this affects ALL Entry Locators
Shadow          USTRING(40)    ! The locator entry's USE variable: wide, so typed text outside the ANSI code page survives

ABBrowse.CLW

Code Excerpts, have not tried to understand its impact. Need to review where .Shadow is set and all use.

!14438 Old Code
FilterLocatorClass.UpdateWindow PROCEDURE
FN  CSTRING(100),AUTO
SN  CSTRING(100),AUTO
  CODE ...
    SN = CHOOSE(INSTRING('UPPER(',FN,1,1) = 0,QUOTE(SELF.Shadow),QUOTE(UPPER(SELF.Shadow)))
    IF SELF.FloatRight
      SELF.ViewManager.SetFilter(CHOOSE(SN='','','INSTRING('''&SN&''','&FN&',1,1) <<> 0'),'3 Locator')
    ELSE
      IF LEN(SELF.Shadow)>0
         SELF.ViewManager.SetFilter('SUB('&FN&',1,'&LEN(SELF.Shadow)&') = '''& SN & '''','3 Locator')
      ELSE
!14487 New Code ... note above in INC file "Shadow" chnaged from CSTRING to wide USTRING... so code is always wide?
FilterLocatorClass.UpdateWindow PROCEDURE
FN  CSTRING(100),AUTO
SN  CSTRING(100),AUTO
  CODE ...
    SN = 'Locator' & ADDRESS(SELF.Shadow)  !Address makes it Unique per Class Instance
    BIND(SN,SELF.Shadow)                   !BIND() removed by POPBIND at return
    IF INSTRING('UPPER(',FN,1,1)
       SN = 'UPPER(' & SN & ')'
    END
    IF SELF.FloatRight
      SELF.ViewManager.SetFilter(CHOOSE(LEN(SELF.Shadow) = 0,'','INSTRING('&SN&','&FN&',1,1) <<> 0'),'3 Locator')
    ELSE
      IF LEN(SELF.Shadow)>0
         SELF.ViewManager.SetFilter('SUB('&FN&',1,'&LEN(SELF.Shadow)&') = '& SN,'3 Locator')
 
    ! The typed text reaches the filter as a BOUND variable, never as a literal: a filter expression is narrow
    ! text, so a literal loses every character outside the ANSI code page, while the bound USTRING keeps its
    ! units and the expression evaluator compares them with a wide column directly. The name is unique per
    ! object (two conditional locators in one procedure must not share it) and needs no quoting of the value.
    ! The window's PUSHBIND/POPBIND (WindowManager.Init/Kill) scopes the name, as it does every BIND the
    ! classes make; an UNBIND of its own would run after that POPBIND and post an error the caller could read.
          

ABReport.INC and ABReport.CLW

ReportManager CLASS(WindowManager),TYPE,...
!14487 adds new Method
HasPreviewer        PROCEDURE(),BYTE ! TRUE when a previewer is attached: Preview (PrintPreviewClass) or PreviewI (IReportPreviewer)

! A ReportPreviewClass is not a PrintPreviewClass by type, so it arrives through the IReportPreviewer Init and
! leaves Preview NULL. Code that asks "is there a previewer?" tests this instead of SELF.Preview alone.
ReportManager.HasPreviewer        PROCEDURE()
 CODE
    RETURN CHOOSE(NOT SELF.Preview &= NULL OR NOT SELF.PreviewI &= NULL)

Template changes in 14487 from 14438


ABBrowse.TPW

#OROF('USTRING') added 2 places so treated like STRING for Thumb and %StepManagerXxxxxType.
Generated CLWs see USTRING change from StepRealClass to StepStringClass

ABProcs.TPW

Same as above #OROF('USTRING') added 3 places so treated like STRING.

ABProgrm.TPW

%InitialValue gets USTRING handling like STRING. New #ELSIF checks for U'' prefix on Initial Value so it does not output something like =''U''''value'''''. Second #ELSEIF adds OR %FieldType = 'USTRING'

    #ELSIF(UPPER(SUB(%InitialValue,1,2))='U''' AND SUB(%InitialValue,LEN(%InitialValue),1)='''' AND LEN(%InitialValue)>3)
      #! A U'' wide literal is a complete string expression already - assigned as it stands
    
    #ELSIF((%FieldType = 'STRING' OR %FieldType = 'CSTRING' OR %FieldType = 'PSTRING' OR %FieldType = 'USTRING') AND SUB(%InitialValue,1,1) ~= '''')
      #! If the user want to add () parenthesis to the the string initial value then the whole initial value must be between single quotes
      #IF(NOT (INSTRING('(',%InitialValue) AND INSTRING(')',%InitialValue)))
    	   #SET(%InitialValue, %SVStripPling(%InitialValue))
      #ENDIF
    #ENDIF

Validation INLIST adds USTRING treatment adding check OR %FieldType = 'USTRING'

#AT(%FieldLevelValidation),WHERE(ITEMS(%FieldValues) AND (%FieldValidation = 'INLIST')),PRIORITY(6000)
...
#IF(%FieldType = 'STRING' OR %FieldType = 'USTRING' OR %FieldType = 'MEMO')
IF INSTRING(']' & CLIP(%Field) & '[', %CDList, 1, 1) = 0

ABWApp.TPW, ABWBrw ABForm ABWRep ABWCus - WApp WBrowse WForm WReport

Major feature Wizards add FONT code to ABWCus.TPW that the others use to allow Developer to set the Window Font.

#GROUP(%DefaultFontWizardPrompts)
#! The wizard's Theme page: the developer's choice to take the default font (Tools > Options > Clarion >
#! Applications) for the windows the wizard makes; shown only when a face is set.
#ENABLE(%DefaultWindowFontName<>'')
  #PROMPT('Use my default font for the windows',CHECK),%QuickUseDefaultFont,AT(90,,235),DEFAULT(%True)
  #DISPLAY('(' & %DefaultWindowFontName & ' ' & %DefaultWindowFontSize & ', from Tools > Options > Clarion > Applications)'),AT(105,,220)
  #DISPLAY('(unchecked = the theme''s fonts)'),AT(105,,220)
#ENDENABLE

Legacy CONTROL.TPW and CtlBrowA.TPW

Like ABProgrm.TPW %InitialValue gets USTRING handling like STRING. New #ELSIF checks for U'' prefix on Initial Value so it does not output something like =''U''''value'''''. Second #ELSEIF adds OR %FieldType = 'USTRING'.

       #ELSIF(UPPER(SUB(%InitialValue,1,2))='U''' AND SUB(%InitialValue,LEN(%InitialValue),1)='''' AND LEN(%InitialValue)>3)
          #! A U'' wide literal is a complete string expression already - assigned as it stands
       #ELSIF((%FieldType = 'STRING' OR %FieldType = 'CSTRING' OR %FieldType = 'PSTRING' OR %FieldType = 'USTRING') AND SUB(%InitialValue,1,1) ~= '''')
          #!%FieldValidation = 'INLIST' AND
          #SET(%InitialValue, %SVStripPling(%InitialValue))

Legacy CtlBrow.TPW

What I see as a BIG CHANGE the Legacy Browse Incremental, Filtered and Entry Locator changes from STRING to USTRING for ALL Keys i.e. so existing STRING types will generate code to process locators as wide USTRING. Simple change from STRING to USTRING, but no other changes to the logic. It assumes no UTF-32 which is reasonable. E.g. if Backspace is pressed if removes 1 character.

14438 Old Code 14487 New Code
#IF(%BrowseLocatorType='Incremental' OR ...='Filtered') #IF(%BrowseLocatorType='Incremental' OR ...='Filtered')
#SET(%ValueConstruct,%BrowsePrefix & ':LocatorValue') #SET(%ValueConstruct,%BrowsePrefix & ':LocatorValue')
%[20]ValueConstruct CSTRING(31) %[20]ValueConstruct USTRING(31) <--- Wide String
#SET(%ValueConstruct,%BrowsePrefix & ':LocatorLength') #SET(%ValueConstruct,%BrowsePrefix & ':LocatorLength')
%[20]ValueConstruct BYTE %[20]ValueConstruct BYTE
#ELSIF(%BrowseLocatorType='Entry') #ELSIF(%BrowseLocatorType='Entry')
#SET(%ValueConstruct,%BrowsePrefix & ':LocatorValue') #SET(%ValueConstruct,%BrowsePrefix & ':LocatorValue')
%[20]ValueConstruct STRING(30) %[20]ValueConstruct USTRING(31) <--- Wide String
#ENDIF #ENDIF

Other

ABWDctP.TPW ABC Dictionary Print Wizard adds #OROF('USTRING') to #GROUP(%ConstructType)
WDctPrn.TPW Legacy Dictionary Print Wizard adds #OROF('USTRING') to #GROUP(%ConstructType)
ADO.TPW adds many #OROF('USTRING')
QCenter.TPW - BrowseQBEList adds two #OROF('USTRING') to treat as 'datatype:string'
Standard.TPW adds #OROF('USTRING') to treat as String for %StandardViewFilter, plus OR %FieldType='USTRING' for %StandardWriteViewOrder

Agreed, and done for the next refresh. The Clarion-chain locator value is now typed from the key component it locates on: a USTRING key gets a USTRING(31) locator value, any other key keeps what 14438 generated - CSTRING(31) for an Incremental or Filtered locator, STRING(30) for an Entry locator. The filter still reaches the view through the bound variable, which works for both types, so that part of the generated code stays as it is in 14487.

On your zips: SchoolLegacyTPS regenerates with all ten locators narrow again, the same declarations as 14438. SchoolLegacyTpsW keeps USTRING(31) on the seven locators over USTRING keys (LastName, Description) and goes narrow on the three over LONG keys (GradYear, Department, Number). Both build.

The ABC side stays as it is: EntryLocatorClass.Shadow is a class member, so it is USTRING(40) for every app; the class works unchanged over narrow keys and there is no per-app code to change.

The next refreshed build carries the change.