CBG Workshop Michael Zille Uniface 9 What‘s new? Stichworte • • • • • • • • • UDE Unicode Farbverwaltung Widgets Dynamische Formlayout-Änderungen XML Reader/Writer Integrierter Serverpage-Editor Proc Statements/Functions Migration Application Platform Suite UDE - Enhancements UDE Look and Feel Multi Language Support (Unicode) •Internationaler Standard für Zeichen bzw. Textelemente •Codebereiche •UCS-2, 16 Bit => 65.536 Zeichen •UCS-4, 32 Bit => 1.114.112 Zeichen derzeit zu etwa 9 % genutzt •Formate •UTF-8 •UTF-16 •... •Unicode Consortium (seit 1991) •Zusammenarbeit mit ISO (Norm 10646) •String literals •Messages •Menu text •Panel text •widgets Restrictions • No Unicode support for: – – – – – CHUI Profile Characters Uniface Names Enhanced Printing in non-Windows platform SQL (/workbench), database error messages, username and password – C, Tuxedo and Corba Call-In and Call-Out – UHTTP components – UPOPMAIL components • No Unicode sorting support • Supported Databases ORACLE, SOLID • „external Interfaces“ e.g. Filenames (supported on Windows, not on UNIX) $DEF_CHARSET default character set used for storing data in String fields with C packing code $SYS_CHARSET Specify the character set used for communication with the operating system and for communication between Uniface and non-Uniface components, if they are not Unicodebased. Support for Unicode and other Character Sets Multi Language Support „Special strings“ does not exist anymore •ASCII (ASC) (font0) uses Unicode Range 0-7F •Extended ASCII (MUL) use Unicode Rage 0-ff (formerly font 0 & 1) •Full Character Set (FUL) –DEFAULT – is determind by $FULL_SYNTAX (font 0 to 7) Assignment Settings • [META_LANGUAGE] Section • $EXTENDED_SYNTAX Specify which characters are allowed as extended characters (~& or ~@) in the field syntax definition. • $FULL_SYNTAX Specify the allowed character set for the FUL shorthand code in the field syntax definition. • $META_IN_TRX Set the data storage format of String fields with the U* packing code to XML or TRX. • $WIDE_CHAR_BEHAVIOR Specify the character set used for String fields with the W packing code. • $GAIJI Allow the use of Japanese Gaiji characters. GUI - Enhancements Color Handling • Widgets – Color List – Color Box • Functions & Statements – $windowproperties($instancename)="backcolor=COLOR„ – $fieldproperties(fld_test)="backcolor=COLOR·;forecolor=COLOR" – colorbox/full • Properties – Windows Properties • Background Color – Widget Properties • Background Color • Foreground Color Enhanced Grid Widget • Supports Windows XP & Vista look and feel • Supports now the following widget types – – – – – – – Editbox Checkbox Picture Command button Spin Button Drop-down List Color box Enhanced Tree Widget Delete Items Re-order Dynamic Menus Dynamic Menus Dynamic Menus Proc Functions & Statements $paintedfieldproperties („myfield1“, „2“, „Xpos;Ypos“)= „Xpos=20;Ypos=15“ $paintedfieldproperties( Field , {PaintedOccurrence ,} { PropertyList} ) {=} PropertyValuesList PropertyValuesList = $paintedfieldproperties( Field , PaintedOccurrence {, Position | Size} ) $paintedfieldproperties $paintedfieldproperties( Field , {PaintedOccurrence ,} { PropertyList} ) {=} PropertyValuesList PropertyValuesList = $paintedfieldproperties( Field , PaintedOccurrence {, Position | Size} ) $paintedfieldproperties (NAME, 4) = "xsize=3;ysize=25" $paintedfieldproperties (NAME.PROJECT.MYORG, "3;4;1") = "xsize+=2" $paintedfieldproperties(FIELD1,"1") = "XPos=50;YPos=50" New Statements file/directory management dircreate dirdelete dirrename Creates the specified directory Deletes the specified directory Renames the specified directory filecopy filedelete filemove filerename Copies the specified file to the target location Deletes the specified file Moves the specified file to the target location Renames the specified file within the same directory Use of Zip-files These instructions can create, read, and write zip files and directories. (Local) File I/O: filedump fileload lfiledump lfileload ZIP unlock flush lflush (Local) directory management: ldircreate ldirdelete ldirrename $ldir $ldirlist dircreate dirdelete dirrename (Local) file management: lfilecopy filecopy lfiledelete filedelete lfiledump filedump lfileload fileload lfilemove filemove lfilerename filerename $lfileexists $lfileproperties Use of Zip-files Zip Path Assignments Assignment file redirections now accept zip archive definitions. For example: [FILES] ; All forms compiled into a ZIP archive *.frm = myforms.zip:*.frm ; All xml files are imported from the sources ZIP in the installation directory umeta.xml = usys:..\sources\sources.zip:umeta.xml usource.xml = usys:..\sources\sources.zip:usource.xml udefault.xml = usys:..\sources\sources.zip:udefault.xml $UDE Perform actions on Repository data, including compiling, exporting, importing, and converting. Syntax Export Repository data: $ude ("export", ObjectType , ObjectProfile ,{ZipArchive :}Filename {, OptionList} ) Import data into the Repository: $ude ("import", "misc",{ZipArchive :}Filename {,"", OptionList} ) Copy or convert data from one format to another: $ude ("copy","misc", Source , Target {, OptionList} ) Compile development objects: $ude ("compile", ObjectType , ObjectProfile {,"", OptionList} ) Note: $ude only works on the development Repository and requires a fully configured Uniface Development Environment and Repository to be available. entitycopy Copy data from one DBMS or file to another. Syntax entitycopy Source , Target {, OptionList} Description The entitycopy Proc statement copies or converts one or more entity occurrences from a source database or file to another. It enables you to incorporate the functionality provided by the /cpy command line switch into your Uniface application. Miscellaneous Functions • $procreturncontext • $itemcount • $string $procreturncontext Return context information about the return value of the previous Proc instruction. Syntax: $procreturncontext Description The $procreturncontext function provides additional information for Proc instructions that are typically involved in batch processing, such as copying data. For example, it can be used after entitycopy and $UDE. $procreturncontext Item Description Context = Context Context of the information. Can have the value EntityCopy, UDE Copy, UDE Import, or UDE Compile. If the Context is UDE Compile, only Release is available Error = Number Error number if process failed on error InputRecords = Number Number of records to be copied. OutputRecords = Number Number of records where an attempt was made to write them. The difference between InputRecords and OutputRecords is the number of void mappings. WriteErrorsContinues = Number Number of write errors encountered that did not stop the copy action. InputDescriptors= Number Number of descriptors to be copied. The same descriptor can occur more than once. OutputDescriptors = Number Number of signatures actually output. This can be less than the number of InputDescriptors if void mappings are encountered. InputTrxFiles = Number Number of TRX files to copy, if a wildcard was specified. InputXmlFiles = Number Number of XML files to copy, if a wildcard was specified. Release = ReleaseNumber Number of the Uniface release of the source data. AdditionalInfo = String Reserved for future $itemcount Return the number of items in a list. Syntax $itemcount ( List ) Description The $itemcount function enables you to determine how many items are in a list before processing each item. variables string vListe endvariables putlistitems/id vListe, order_id.order, total.order message/info "Number of Items: %%$itemcount(vListe)%%%" $string Return a string containing the replacement of each named XML entity in the input parameter string by the character represented by the entity. (XML entities are character mappings; they are not the same as Uniface entitites.) Syntax $string ( String ) In the following examples, FLD is a String field whose packing code is W*. vVar1=$string("XML has five predeclared entities.") ;0 xml entity vVar2=$string("They are: &lt;, &gt;, &amp;, %\ &apos;, and &quot;.") ;5 xml entities FLD=„%%vVar1%%%%%^%%vVar2%%%“ After executing this Proc, field FLD contains the following: XML has five predeclared entities. They are: <, >, &, ', and ". $string Variables string vVar1 string vVar2 string vFLD endvariables ;GrossBuchstaben vVar1=65 vVar2="" while(vVar1 < 91) vVar2="%%vVar2%%%&#%%vVar1;%%%" vVar1=vVar1+1 endwhile FLD_W=$string(vVar2) After executing this Proc, field FLD_W contains: ABCDEFGHIJKLMNOPQRSTUVWXYZ XML – Reader / - Writer XML -Reader / -Writer • • • • It enables the procedural creation and parsing of XML strings It is comparable to SAX parser Use UXMLWRITER to generate a XML file or data stream Use UXMLREADER to parse an existing XML file or data stream Simple API for XML (SAX) •Die Simple API for XML (SAX) ist ein Pseudo-Standard, •der ein Application Programming Interface (API) zum Parsen von XML-Daten beschreibt. •Die aktuelle Hauptversion SAX 2.0 wurde 2000 von David Meggionson veröffentlicht und •ist Public Domain. •Ein SAX-Parser liest XML-Daten als sequentiellen Datenstrom und ruft für im Standard definierte Ereignisse vorgegebene Rückruffunktionen (callback function) auf. •Eine Anwendung, die SAX nutzt, kann eigene Unterprogramme als Rückruffunktionen registrieren und auf diese Weise die XML-Daten auswerten. Simple API for XML (SAX) <?xml version="1.0"?><doc><para> Hello, world!</para> </doc> <?xml version="1.0"?> <doc> <para> Hello, world! </para> </doc> start document start element: doc start element: para characters: Hello, world! end element: para end element: doc end document XML-Reader • STARTDOCUMENT activated when the parser starts reading the document. • STARTELEMENT activated when the parser encounters a start tag, for example <tag doc> • CHARACTER activated when character data is encountered between a tag and its end tag. • ENDELEMENT activated when the parser encounters an end-tag such as </tag doc>. • ENDDOCUMENT activated when the end of the document is reached. XML-Reader operation startdocument ; your code end ;-------------------------> operation enddocument ; your code End operation warning | error | fatalerror params string list: in endparams ; your code end operation startelement params string name: in string attr: in endparams ; your code end ;----------------------------> operation endelement params string name: in endparams ; your code end operation characters params string chars: in endparams ; your code end To create a SAX handler: 1. Create a component that implements at least one SAX callback operation. These operations are activated by the PARSE and PARSEFILE operations of the UXMLREADER component. 2. Optionally, implement error handling operations to handle invalid data and other errors. Data read by the parser is expected to be legal—either there is no DTD defined for the data, or if there is a DTD, the tags, attributes and character data conform to the DTD. If this is not the case, the appropriate operation is activated, if present. • • • • For warnings, the WARNING operation is activated. If the error is deemed recoverable by the SAX parser, the ERROR operation is activated; otherwise, the FATALERROR operation is activated. If there is no ERROR operation, recoverable errors are silently recovered from and ignored. After a fatal error occurs, no further processing of the XML file is done and the PARSE or PARSEFILE operation returns a negative value. To read and parse an XML document: 1. Create an instance of the UXMLREADER component. 2. Create an instance of the handler component, or retrieve the instance name of an already active handler component. 3. Activate the handler by calling the SETHANDLER operation. 4. Start parsing XML documents using PARSE to parse a field or variable of type string or xmlstream, or PARSEFILE to start parsing a file. As the XML document is parsed, the operations in the handler instance are activated based on what the parser encounters in the XML document. When PARSE or PARSEFILE returns, either the entire XML document has been successfully parsed, or a fatal error has occurred, in which case a negative return value is returned. XML-Writer • internal Uniface component that enables you to generate XML documents • The UXMLWRITER component operations enable you to construct an XML document. • The operations must be called in a specific sequence. • • • • • • • STARTDOCUMENT ENDDOCUMENT STARTELEMENT ENDELEMENT ADDATTRIBUTE CHARACTERS DOCCOMMENT • GETDOCUMENT To generate an XML document: 1. For each XML document you want to generate, create an instance of the UXMLWRITER component. 2. Call the STARTDOCUMENT operation for each instance. 3. Add XML elements, attributes and comments using the operations available on the UXMLWRITER component. 4. Retrieve the resulting XML documents with the GETDOCUMENT operation. 5. Manipulate the data as required. 6. Delete the instances of UXMLWRITER when they are no longer required. Integrated Web Development Integrated Web Development • No generation of HTML Skeletons • USP layout information is incorporated into the server page itself • Complete definition is stored in the repository and compiled into the .usp files • The integrated graphical HTML layout editor is the main tool for defining server pages • Component editor for: • • • • view data structure load fields define properties write proc code Migration CBG Workshop Zeit für Fragen