vrijdag 11 juli 2014

Updating individual component properties

When you want to do some mass updates to your Uniface application the Global Updates functionality can be of great help. But every once in a while there is something the Global Updates cannot do for you.

I wanted to update one of the More Properties of my components and I found out that Global Updates always replace the complete set of component properties with the new set that you have specified. That was not what I wanted because that would override all the properties that I have so carefully set per functional type of component.

So I made a litte tool.

Attached is a Form that fulfilled my requirements.
With this form you can:

  • Add a property when it does not exist
  • Add a property when it does not exist and update the value if it does exist
  • Change the value of a property when it exists
  • Delete a property
  • Delete a property if it has the specified value

To use this, press the download button below. Unzip the file. Import it into a Uniface dictionary. Make sure you have the DICT model in there. Compile and run Form A_PROPERTIES.




woensdag 7 mei 2014

Uniface: Casting in an if statement





Another great Uniface blog entry by Rik Lewis.

Have a look at it:

Uniface: Casting in an if statement (equality versus identi...:

Uniface is a tightly typed language - this means that when we declare variables, we also declare the datatype, such as string or numeric, l...

dinsdag 6 augustus 2013

An Office-style File menu in Uniface

Have you ever looked closely at the File menu of the MS-Office product? When you look closely you will see that these menus are graphically much more complex than you would think. After some experimenting I managed to replicate it in Uniface 9.6.

You need some Command Buttons and a TabEx widget. In the download you find the logical widget definitions and the images that I used. And in the Uniface form so you can see how it works.

I am no legal expert but you may want to modify this sample before you use it in a production application because you don't want to infringe Microsoft's copyright.



maandag 1 juli 2013

Blend in your HTML Widget

Just a little trick to make an HTML widget blend in better with the rest of your application.


Two aspects:

  1. Get the background color that is used in your application
    I retrieve the color from the .ini file. You could also use $windowproperties to get the backcolor of the window.
  2. Set the background color of the HTML using JavaScript.
    The use of the eval function means that you do not have to include a JavaScript function in your HTML, meaning you can even use this for external websites.


; Set background color of the HTML widget to 
; the color specified in the backcolor property of 
; the window logical widget in 
; the [application] section of the .ini file
call lpGetSetting("application\window","backcolor",vColor)
if (vColor <> "")
   show
   $fieldhandle("TEXT.DUMMY")->$widgetoperation( "JS:eval(%%"document.body.style.backgroundColor = '%%vColor%%%';%%")")
endif
end


entry lpGetSetting
params
   string pSetting : IN
   string pTopic : IN
   string pValue : OUT
endparams
variables
   string vTopics
endvariables

   vTopics = $setting("", pSetting, "INIDATA")
   vTopics = vTopics[$scan(vTopics,"(")+1]
   vTopics = vTopics[1:$rscan(vTopics,")")-1]
   vTopics = $replace(vTopics, 1, ";", "·;", -1)
   getitem/id pValue, vTopics, pTopic

end

maandag 10 juni 2013

A Facebook Like button in Uniface

This is really simple:

  1. Determine the URL of what you want your Like button to like.
    If it is a posting you have to hover over the timestamp to see the URL.

  2. Paint an HTML Widget on your Uniface Form.

  3. Assing the following string to the widget:
    "&http://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2FUnisocialCommunity%2Fposts%2F382515988535596&send=false&layout=button_count&width=450&show_faces=true&font&colorscheme=light&action=like&height=21&appId=222806551068648"

  4. Now the Like button goes to one of my postings.
    To change that replace the URL in the href parameter with your own URL. Use URL encoding, %2F is a foward slash. So you have to replace this bit:
    https%3A%2F%2Fwww.facebook.com%2FUnisocialCommunity%2Fposts%2F382515988535596

  5. Compile and run!
    (If you are not logged on to Facebook yet, a login dialog will appear after you have pressed to button.  Please follow the instructions in the dialog.)

Needless to say that this is just as easy in a Uniface Web application...

maandag 1 april 2013

Recursive Indirection

"Recursive indirection". That sounds pretty impressive but I guess it does not mean much to you without some explanation. Here it comes:

You all know how to assign a value to a variable  in Uniface:
vValue = "Hello world"

And you also know how to assign to value of a field to a variable:
WELCOMETEXT.DUMMY = "Hello world"
vValue = WELCOMETEXT.DUMMY

Most of you also know that you can use indirection.
With indirection you have a field that contains the name of another field., and you use this to assign the value of that field to a variable:

WELCOMETEXT.DUMMY = "Hello world"
WELCOMEFIELD.DUMMY = "WELCOMETEXT.DUMMY"
vValue = @WELCOMEFIELD.DUMMY

Not many people know that (in recent Uniface versions) you can do this recursively:
WELCOMETEXT.DUMMY = "Hello world"
WELCOMEFIELD.DUMMY = "WELCOMETEXT.DUMMY"
WHATFIELD.DUMMY = "WELCOMEFIELD.DUMMY"
vValue = @@WHATFIELD.DUMMY

You probably do not need this often, but it can be valuable in complex user interfaces or maybe a software package that is highly configurable. Don't forget to put in some comments when you use this: it is powerful but it does not make your code easy to understand for your fellow developers!





maandag 11 maart 2013

Sneak preview

In this picture you see some new stuff that is planned (!) for release in Uniface 9.6.02.

Can you see what the differences are without looking at the answers below?