tag:blogger.com,1999:blog-46608600573609116772024-03-05T23:32:57.518+00:00UnifaceTips and tricks picked up by a Uniface developer over the yearsAnonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.comBlogger66125tag:blogger.com,1999:blog-4660860057360911677.post-66245706391549524352016-08-12T17:00:00.000+01:002016-08-12T17:00:11.707+01:00Scanning is slow - should I split?<span style="font-family: Arial, Helvetica, sans-serif;">Almost 4 years ago, I wrote a post entitled <a href="https://uniface.blogspot.co.uk/2012/08/scanning-is-slow.html" target="_blank">Scanning is slow</a>. Well, to be fair, it is.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The example code that I gave was for counting how many times a substring appeared within a string...</span><br />
<br />
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="color: green; font-family: "Courier New"; font-size: 10pt;"> </span><span style="font-family: "Courier New"; font-size: 10pt;">temp = list<o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="font-family: "Courier New"; font-size: 10pt;"> total = 0<o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10pt;">scan </span><span style="font-family: "Courier New"; font-size: 10pt;">temp,</span><span style="color: purple; font-family: "Courier New"; font-size: 10pt;">"ABC"<o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="color: purple; font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10pt;">while </span><span style="font-family: "Courier New"; font-size: 10pt;">( </span><span style="color: red; font-family: "Courier New"; font-size: 10pt;">$result </span><span style="font-family: "Courier New"; font-size: 10pt;">> 0 )<o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="font-family: "Courier New"; font-size: 10pt;"> total = total+1<o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="font-family: "Courier New"; font-size: 10pt;"> temp = temp[<span style="color: red;">$result</span>+3]<o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10pt;">scan </span><span style="font-family: "Courier New"; font-size: 10pt;">temp,</span><span style="color: purple; font-family: "Courier New"; font-size: 10pt;">"ABC"<o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="color: purple; font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10pt;">endwhile</span></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">I gave a perfectly simply alternative which performed much better in this scenario, using <b>$replace</b> and <b>$itemcount</b>. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">However, I found myself in a similar situation yesterday, but I couldn't use this trick, because I needed to loop through, searching for certain substrings, but without changing the string that I was looping through.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">A thought occurred to me, which was that I was always taking the string from after the value I'd found and scanning again, so in this case, what about using <b>$split</b> instead?</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">To compare against to above, I came up with something like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="color: green; font-family: "Courier New"; font-size: 10pt;"> </span><span style="font-family: "Courier New"; font-size: 10pt;">temp = list<o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">
<span style="font-family: "Courier New"; font-size: 10pt;"> total = 0</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: red; font-family: "Courier New"; font-size: 10.0pt;">$result </span><span style="font-family: "Courier New"; font-size: 10pt;">= </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">$split</span><span style="font-family: "Courier New"; font-size: 10pt;">(temp,1,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ABC"</span><span style="font-family: "Courier New"; font-size: 10pt;">,lhs,rhs)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">while </span><span style="font-family: "Courier New"; font-size: 10pt;">( </span><span style="color: red; font-family: "Courier New"; font-size: 10.0pt;">$result </span><span style="font-family: "Courier New"; font-size: 10pt;">> 0 )<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> total = total+1<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> temp = rhs<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: red; font-family: "Courier New"; font-size: 10.0pt;">$result </span><span style="font-family: "Courier New"; font-size: 10pt;">= </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">$split</span><span style="font-family: "Courier New"; font-size: 10pt;">(temp,1,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ABC"</span><span style="font-family: "Courier New"; font-size: 10pt;">,lhs,rhs)</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 115%;">endwhile</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I tested this by doing 500 iterations, on a string with 500 instances (so <b>total</b> was 250000 at the end)...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>$scan</b>: 20.94, 20.67, 20.85 - almost 21 seconds.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>$split</b>: 27.09, 27.48, 26.83 - around 27 seconds.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">So <b>$split</b> definitely looked worse off, it looked like</span><span style="font-family: Arial, Helvetica, sans-serif;"> </span><b style="font-family: Arial, Helvetica, sans-serif;">$scan</b><span style="font-family: Arial, Helvetica, sans-serif;"> was better suited to what I needed (as I wasn't interested in the left hand side).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">However, these tests have been seeing whether I can use <b>$split</b> to improve my <b>$scan</b> loop, and this seemed a little unfair now I'd proven it couldn't, so I thought I'd flip it on it's head and see if <b>$scan</b> is better at doing what <b>$split</b> is designed for.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">So for <b>$split</b> this is quite easy, a simple line which splits the string into two parts...</span><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: red; font-family: "Courier New"; font-size: 10pt;">$result </span><span style="font-family: "Courier New"; font-size: 10pt;">= </span><span style="color: blue; font-family: "Courier New"; font-size: 10pt;">$split</span><span style="font-family: "Courier New"; font-size: 10pt;">(temp,1,</span><span style="color: purple; font-family: "Courier New"; font-size: 10pt;">"~"</span><span style="font-family: "Courier New"; font-size: 10pt;">,lhs,rhs)</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Using <b>$scan</b> this is a little more complicated, and requires a little string manipulation...</span><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: red; font-family: "Courier New"; font-size: 10pt;">$result </span><span style="font-family: "Courier New"; font-size: 10pt;">= </span><span style="color: blue; font-family: "Courier New"; font-size: 10pt;">$scan</span><span style="font-family: "Courier New"; font-size: 10pt;">(temp,</span><span style="color: purple; font-family: "Courier New"; font-size: 10pt;">"~"</span><span style="font-family: "Courier New"; font-size: 10pt;">)</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> lhs = temp[1:$result-1]</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> rhs = temp[$result+1]</span></div>
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;">When I compared the two over 2,000,000 iterations, I got these results...</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>$split</b>: 10.19, 9.78, 10.01 - around 10 seconds.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>$scan</b>: 16.60, 16.51, 16.82 - over 16 seconds.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">So I've worked out that <b>$split</b> is good for splitting and <b>$scan</b> is good for scanning... Why am I writing this up in a blog post, you might wonder!</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Well I then considered the fact that I was splitting a string on a delimiter that I knew existed. And in the real world situation I was working on, this wasn't a fair assumption, as often the delimiter would not be there. So I tried this again, but with a different delimiter, that wouldn't be found in the string...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>$split</b>: 10.66, 10.73, 10.87 - a little over 10 seconds.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>$scan</b>: 9.20, 9.00, 8.44 - around 9 seconds.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">So it looks like it's not quite as straightforward as I thought. However, the saving when it is found is quite a lot larger than the loss when it's not found, so maybe <b>$split</b> is still best overall.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: If you're looking to scan through a string, use <b>$scan</b>, and if you're looking to split a string (especially if you expect the delimiter to be there), use <b>$split</b>.</span><br />
<br />Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-64589208398456245992016-07-08T09:19:00.000+01:002016-07-08T09:19:09.955+01:00Training videos for Uniface developers<span style="font-family: Arial, Helvetica, sans-serif;">Yesterday there was a blog post by <i>Ton Blankers</i> on Uniface.info covering <a href="http://unifaceinfo.com/html5-javascript-css3-training-videos-uniface-developers-uniface-info/" target="_blank">HTML5, Javascript and CSS3 Training Videos for Uniface Developers</a>. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This post highlights a special series of training videos on web topics for Uniface developers. They are available on Uniface.info, and include both introductory and more advanced videos.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">They're well worth checking out, as they cover things like Canvas, Geolocation, LocalStorage, JSON and more.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Check out the <a href="http://unifaceinfo.com/html5-javascript-css3-training-videos-uniface-developers-uniface-info/" target="_blank">full blog post here</a> for more details and links to the videos.</span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-55674123777928789722016-06-17T19:05:00.000+01:002016-06-17T19:05:00.805+01:00Putlistitems - successive occurrences<span style="font-family: arial, helvetica, sans-serif;">I've used </span><b style="font-family: arial, helvetica, sans-serif;">putlistitems</b><span style="font-family: arial, helvetica, sans-serif;"> a lot, it's very useful. Different switches all it to do different things, so for example, </span><b style="font-family: arial, helvetica, sans-serif;">/occ</b><span style="font-family: arial, helvetica, sans-serif;"> will populate a variable with an associative list of field names and values, something like this...</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<div class="MsoNormal">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;"> putlistitems</span><span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%;">/occ varMyList,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"ENT"</span><o:p></o:p></div>
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">"varMyList" will now be something like "FIELD1=VALUE1·;FIELD2=VALUE2·;etc".</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">This can further be modified by adding <b>/modonly</b>, which will only add field values to the list which have been modified since the record was retrieved, something like this...</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 15.3333px;"> putlistitems</span><span style="font-family: "Courier New"; font-size: 10pt; line-height: 15.3333px;">/occ/modonly varMyList,</span><span style="color: purple; font-family: "Courier New"; font-size: 10pt; line-height: 15.3333px;">"ENT"</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">However, the one I tend to use most is <b>/id</b>. This will take the values of the specified field from multiple occurrences and put them into a list, something like this...</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> varMyList = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"FIELD1"</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 115%;"> putlistitems</span><span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%;">/id varMyList</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">"varMyList" will now be something like </span><span style="font-family: arial, helvetica, sans-serif;">"VALUE1·;VALUE1</span><span style="font-family: arial, helvetica, sans-serif;">·;etc</span><span style="font-family: arial, helvetica, sans-serif;">", repeated for each occurrence.</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">This allows you to quickly grab the values of the field(s) you're interested in, without having to loop through the occurrences in order to build the list, which is much better for performance.</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">Or you can also use it to update the representations in a list, for example, backing up a load of field or register values...</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> varMyList = </span><span style="color: purple; font-family: "Courier New"; font-size: 10pt;">"$1</span><span style="color: purple; font-family: "Courier New"; font-size: 10pt; line-height: 115%;">·;$2</span><span style="color: purple; font-family: "Courier New"; font-size: 13.3333px; line-height: 15.3333px;">·;$3</span><span style="color: purple; font-family: "Courier New"; font-size: 10pt;">"</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 15.3333px;"> putlistitems</span><span style="font-family: "Courier New"; font-size: 10pt; line-height: 15.3333px;">/id varMyList</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">"varMyList" will now be something like </span><span style="font-family: arial, helvetica, sans-serif;">"$1=REG1·;$2=REG2</span><span style="font-family: arial, helvetica, sans-serif;">·;$3=REG3</span><span style="font-family: arial, helvetica, sans-serif;">".</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">All of this is well documented in the Uniface manuals, so you may well be asking me why I'm telling you this. Fair question.</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">I never realised that the first use of <b>/id</b>, taking the values of the specified field from multiple occurrences, was actually <i>successive</i> occurrence. This means that it will start on the current occurrence and loop through to the end, completing the hitlist if required.</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">The manuals make this clear, with the following note...</span><br />
<blockquote class="tr_bq">
<span style="font-family: arial, helvetica, sans-serif;"><i>To ensure that the entire set of occurrences in the component is being addressed, make the first occurrence the current occurrence.</i></span></blockquote>
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">What this means is, use <b>setocc</b> first, like this..</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">setocc</span><span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ENT"</span><span style="font-family: "Courier New"; font-size: 10pt;">,1</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> varMyList = </span><span style="color: purple; font-family: "Courier New"; font-size: 10pt;">"FIELD1"</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 115%;">putlistitems</span><span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%;">/id
varMyList</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">I hope I've not been caught out by this in the past!</span><br />
<span style="font-family: arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">Summary: <b>putlistitems/id</b> will look at successive occurrences, so if you want the whole hitlist, remember to make sure the current occurrence is the first occurrence.</span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-82954492816248945082016-02-24T10:07:00.000+00:002016-02-24T10:07:47.081+00:00Uniface Lectures - Deployment<span style="font-family: Arial, Helvetica, sans-serif;">The first "Uniface Lecture" on Modernisation was really interesting, although it did cover a lot of the same ground as the series of blog posts on Modernisation, which I've also posted about before (<a href="http://uniface.blogspot.co.uk/2015/10/modernising-uniface.html" target="_blank">here</a>, <a href="http://uniface.blogspot.co.uk/2015/11/modernising-uniface-part-2.html" target="_blank">here</a> and <a href="http://uniface.blogspot.co.uk/2015/11/modernising-uniface-part-3.html" target="_blank">here</a>). It went well though, and I expect the rest in the series to be just as good, if not better!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I did get caught out by the setup required (which we were told about in advance, so it's my own fault), so if you don't already have a browser plugin for "Skype for Business" then you should get that sorted out in advance by following <a href="https://support.office.com/en-us/article/Join-a-Skype-Meeting-with-Skype-for-Business-Web-App-4828ad18-ed21-422a-a870-94d676d4b72a" target="_blank">this article</a>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdsGNVitIAnw7iFPLEbObBDqEFk3jJzoEle2ofLi9nuGVHo-w_PSZ6ou0FEiaEsrMDMoSf3FKmv1PZ14qdDJlUTnUEkwxtp6RNOpRRt3MYvm0W9L3AZuXgI6SqkFrDdiESfWLwHkokWlI/s1600/deployment.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="100" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdsGNVitIAnw7iFPLEbObBDqEFk3jJzoEle2ofLi9nuGVHo-w_PSZ6ou0FEiaEsrMDMoSf3FKmv1PZ14qdDJlUTnUEkwxtp6RNOpRRt3MYvm0W9L3AZuXgI6SqkFrDdiESfWLwHkokWlI/s400/deployment.png" width="400" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The next webinar in the series is going to be on Thursday 10th March, 8am and 4pm (CET). </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b><br /></b></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><u><b>Deployment</b></u></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><ul>
<li>Standard deployment (with UAR's) versus classic deployment (with URR's and DOL's) </li>
<li>The benefits of standard deployment </li>
<li>Things to consider when deploying your Uniface application using the 64bit version of Uniface.</li>
</ul>
<div>
Although I'm aware of standard deployment, I've only ever used classic deployment, so I'm interested to find out more about the differences and what I might be missing out on.</div>
<div>
<br /></div>
<div>
<a href="http://go.uniface.com/Lecturesdeployment" style="font-family: arial, helvetica, sans-serif;" target="_blank">Click here for more information and to register</a></div>
<div>
<br /></div>
<div>
<div style="font-family: 'Times New Roman';">
<span style="font-family: "arial" , "helvetica" , sans-serif;">As I said <a href="http://uniface.blogspot.co.uk/2016/02/uniface-lectures.html">in my last post</a>, I'm just passing this information on because I think they'll be useful. If you want more information, or to hear it from the horses mouth, check out the website...</span></div>
<div style="font-family: 'Times New Roman';">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="font-family: 'Times New Roman';">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="http://go.uniface.com/Lectures" target="_blank">http://go.uniface.com/Lectures</a></span></div>
<div style="font-family: 'Times New Roman';">
<br /></div>
<div class="separator" style="clear: both; font-family: 'Times New Roman'; text-align: center;">
<a href="http://go.uniface.com/l/52722/2016-01-28/9ls33q/52722/70829/Lectures_Logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://go.uniface.com/l/52722/2016-01-28/9ls33q/52722/70829/Lectures_Logo.png" height="98" width="320" /></a></div>
</div>
</span><ul type="disc">
</ul>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-74313385100450110782016-02-09T17:57:00.000+00:002016-02-09T17:57:05.620+00:00Uniface Lectures<span style="font-family: Arial, Helvetica, sans-serif;">Uniface have got a new series of "lectures", or webinars, coming up soon. </span><span style="font-family: Arial, Helvetica, sans-serif;">These sound like a great idea, and are covering a range of different subjects.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://go.uniface.com/Lectures" target="_blank"><img alt=" Uniface Lectures" border="0" height="98" src="https://s3.amazonaws.com/storage.pardot.com/52722/70829/Lectures_Logo.png" width="320" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The webinars are one a month, and topics published so far are...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><div>
<u style="font-weight: bold;">Modernization</u> - Thursday 18th February (8am or 4pm CET)</div>
<div>
<br /></div>
<div>
How to give your Uniface applications a Windows 10 look and feel, and how to work with different screen resolutions. </div>
<div>
<br /></div>
<div>
<a href="http://go.uniface.com/Lecturesmodernization" target="_blank">Click here for more information and to register</a></div>
<div>
<br /></div>
<br /><u style="font-weight: bold;">Deployment</u> - <i>Thursday 10th March (TBC)</i></span><div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">How to more easily distribute and update your Uniface applications. <br /><br /> <br /><u style="font-weight: bold;">JavaScript</u><i> - Thursday 14th April (TBC)</i></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">How to use Uniface in existing web pages.<br /><br /> <br /><u style="font-weight: bold;">Mobile</u><i> - Thursday 12th May (TBC)</i></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">How to build your first Uniface mobile app.<br /><br /> <br /><u style="font-weight: bold;">Integration</u><i> - Thursday 16th June (TBC)</i></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">How to integrate your Uniface applications with Dropbox and OneDrive. How to use semantic URLs for Uniface RESTful services.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">I'm just passing this information on because I think they'll be useful. If you want more information, or to hear it from the horses mouth, check out the website...</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://go.uniface.com/Lectures" target="_blank">http://go.uniface.com/Lectures</a></span></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://go.uniface.com/l/52722/2016-01-28/9ls33q/52722/70829/Lectures_Logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://go.uniface.com/l/52722/2016-01-28/9ls33q/52722/70829/Lectures_Logo.png" height="98" width="320" /></a></div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com2tag:blogger.com,1999:blog-4660860057360911677.post-66557313856294473422015-12-23T22:14:00.000+00:002015-12-23T22:14:13.124+00:00Drag and drop<span style="font-family: Arial, Helvetica, sans-serif;">Yesterday I read an interesting article about drag and drop in Uniface, aptly named <a href="http://unifaceinfo.com/drop-it-like-its-hot/" target="_blank">Drop It Like It's Hot</a>. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">It actually goes into plenty of detail about how to add drop areas into your own Uniface forms, which is something I'd definitely like to try some time. But what really interested me was the opening paragraph...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<blockquote class="tr_bq">
<span style="font-family: Arial, Helvetica, sans-serif;"><i>What very little people know is that in the Import Repository Objects component there is a small section where you can drag your export files from Windows Explorer. After you drop them, the File name box is updated with the list of files that you dropped. The red section is where the drag-and-drop field is located.</i></span></blockquote>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://unifaceinfo.com/wp-content/uploads/2015/12/import.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://unifaceinfo.com/wp-content/uploads/2015/12/import.png" height="118" width="400" /></a></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">I tried this today and it definitely works. You learn something new every day!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: You can drag and drop export files onto the Import Repository Objects popup, which is really quick and convenient.</span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-88906840883447192012015-11-10T19:48:00.000+00:002015-11-10T22:24:40.227+00:00Modernising Uniface - part 3<span style="font-family: "arial" , "helvetica" , sans-serif;">Over the past couple of weeks I have posted about <a href="http://uniface.blogspot.co.uk/2015/11/modernising-uniface-part-2.html" target="_blank">Modernising Uniface</a> (and <a href="http://uniface.blogspot.co.uk/2015/10/modernising-uniface.html" target="_blank">here</a>), and this is the third and final post in this series.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The third post from <i>Theo Neeskens</i> was primarily concerning the new flat buttons, which look like this...</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://unifaceinfo.com/wp-content/uploads/2015/10/button-teaser2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://unifaceinfo.com/wp-content/uploads/2015/10/button-teaser2.png" height="205" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">As you can see, the new flat blue buttons, on a white background, are on top of the old grey/grey.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The first thing they needed to do was categorise the different painted button types, and they came up with five...</span></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<ol>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">IDFButtonBottom - for the big buttons at the bottom of dialogs</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">IDFButtonSide - for the big buttons at the right-hand side of dialogs</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">IDFButtonSpecial - for the other buttons</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">IDFButtonImage - for the small buttons without labels (eg. ">>")</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">IDFButtonHeader - for the buttons which make up the header on simulated grids</span></li>
</ol>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So then there are a few jobs that needed to be done...</span></div>
<div>
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Change the properties in the configuration file for these widget types</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Match modelled widgets with painted widgets</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Set the properties on the painted buttons</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Set the properties on the modelled buttons</span></li>
</ul>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://unifaceinfo.com/wp-content/uploads/2015/10/Widget-property-inheritance-300x151.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://unifaceinfo.com/wp-content/uploads/2015/10/Widget-property-inheritance-300x151.png" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
</div>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Again, many of the these jobs were achieved with tools, and all of these have been provided in a zip file, to be downloaded and modified if you wish, but not supported by Uniface and used at your own risk.<br /><br />The full blog post is definitely worth checking out, including the "Wishes" section at the end... <a href="http://unifaceinfo.com/modernizing-uniface-9-7-the-buttons/" target="_blank">Modernizing Uniface 9.7: The buttons</a></span><br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Summary: Uniface has successfully (in my opinion!) modernised it's IDE in version 9.7, meaning we don't have to wait for Uniface 10.</span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-144378429156196262015-11-04T19:09:00.000+00:002015-11-04T19:09:00.112+00:00Modernising Uniface - part 2<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">I posted last week about </span><a href="http://uniface.blogspot.co.uk/2015/10/modernising-uniface.html" style="font-family: Arial, Helvetica, sans-serif;" target="_blank">Modernising Uniface</a><span style="font-family: "arial" , "helvetica" , sans-serif;">, which included my comments about </span><i style="font-family: Arial, Helvetica, sans-serif;">Theo Neeskens</i><span style="font-family: "arial" , "helvetica" , sans-serif;"> post on UnifaceInfo.com. I received some comments that I was talking purely about the IDE, and not the language itself. So let me start by stating that this post of about the modernisation of the IDE, and not the language itself.</span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">This time the post is all about the effort it took to make the seemingly simple move from grey backgrounds (which psychologically make software feel outdated) white clean, clear, white backgrounds, like this...</span><a href="http://unifaceinfo.com/wp-content/uploads/2015/10/old_new.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="http://unifaceinfo.com/wp-content/uploads/2015/10/old_new.png" height="300" width="400" /></a><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /><br />For both of these dialogs, the older grey version sits behind the newer white version. You can also see the buttons have changed, but we've been promised more about those in the next blog post.</span><br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The main problems they hand with this change included...</span></div>
<div>
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Forms having index, foreground or background colour set</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Painted entities having index, foreground or background colour set (and being painted at least 3 characters wide)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Entities having foreground or background colour set in the model</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Grids not having borders</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Multi-occurrence entities not having borders</span></li>
</ul>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">A couple of these have been resolved by making new properties available, but all of them required fix programs to find the affected items and update them to the new properties. All of the tools have been provided in a zip file, to be downloaded and modified if you wish, but not supported by Uniface and used at your own risk.</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I've had my hands on Uniface 9.7 now (which I hadn't when I wrote the first post) and I can say that it definitely feels more up-to-date, and I agree that the white backgrounds and blue buttons are a large part of that. We've actually been changing our web offering to a similar colour scheme over the past few months, so I can't disagree with their choice!<br /><br />Again, the full blog post is definitely worth checking out... <a href="http://unifaceinfo.com/modernizing-uniface-9-7-part-2/" target="_blank">Modernizing Uniface 9.7, Part 2</a>.</span><br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Summary: Uniface is modernising it's IDE, and we're not going to have to wait for Uniface 10 to get in on the action.</span></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-57498434418541542352015-10-15T22:42:00.000+01:002015-10-15T22:42:00.318+01:00Modernising Uniface<span style="font-family: Arial, Helvetica, sans-serif;">Uniface have been putting a lot of work into the new Uniface 10 IDE, and this is something I'm looking forwards to getting my hands on, but it could be a while yet. Good things come to those who wait, they say.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Well the good news is that the delays in Uniface 10 have led to the decision to release a Uniface 9.7. Whilst they may be planning to put limited time into this, whilst focusing their efforts on Uniface 10, it looks like they have big plans to modernise.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In the first of a 10 part series, <i>Theo Neeskens</i> has outlined the objectives and the first set of changes - the start screen.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The objectives were straightforward enough...</span><br />
<br />
<ol>
<li><span style="font-family: Arial, Helvetica, sans-serif;">New start page - Windows 10-esque - big change.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Change grey backgrounds to white backgrounds.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Use trendy flat buttons.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Fresh look and new colour scheme - something different.</span></li>
</ol>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Looks like they met the objectives, based on these screenshots...</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOz6LpfECTL0MztQN4eVgV-VAXV43FspG3zUsD-Y8HGi2jnVjQJ3oTnGELu2sOG29IzTsUI19WVpccfteGTlaovn6Kfur5LBMaioMvBKv_tyMGntXn-198GH0B9dMFjv0SBcEw122hEMU/s1600/Startpage-Old.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOz6LpfECTL0MztQN4eVgV-VAXV43FspG3zUsD-Y8HGi2jnVjQJ3oTnGELu2sOG29IzTsUI19WVpccfteGTlaovn6Kfur5LBMaioMvBKv_tyMGntXn-198GH0B9dMFjv0SBcEw122hEMU/s400/Startpage-Old.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG4UVuaGAEc7IAgiAksFzbcvI5O0ikP9ijvpQAPYqpC1a16yZ-Tpg50SOGKBl6wNq7ASxeWSOxsuh7mHT0p7q5CehzqM_2VFjR4xZXAOZUIZ9N34Lilb1VIazXIvAS0i-bQq1tKIDO8So/s1600/Startpage-New.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="285" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG4UVuaGAEc7IAgiAksFzbcvI5O0ikP9ijvpQAPYqpC1a16yZ-Tpg50SOGKBl6wNq7ASxeWSOxsuh7mHT0p7q5CehzqM_2VFjR4xZXAOZUIZ9N34Lilb1VIazXIvAS0i-bQq1tKIDO8So/s400/Startpage-New.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Now that's a radical change! I think changes like this will be very well received, and help stop people getting such a negative first impression of Uniface as a language.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">The full blog post is definitely worth checking out... <a href="http://unifaceinfo.com/modernizing-uniface-9-7-in-10-easy-steps/" target="_blank">Modernizing Uniface 9.7 in 10 easy steps</a>.</span></div>
<div>
<br /></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Uniface is modernising, and we're not going to have to wait for Uniface 10 to get in on the action.</span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com4tag:blogger.com,1999:blog-4660860057360911677.post-90962085691767911722015-07-24T16:45:00.002+01:002015-07-24T16:45:58.657+01:00Where to put your code<span style="font-family: Arial, Helvetica, sans-serif;">There's an interesting blog post by <a href="http://unifaceinfo.com/author/a4dvo/" target="_blank">Dennis Vorst</a> gone up on the Uniface.info blog, titled <a href="http://unifaceinfo.com/where-to-put-your-code/" target="_blank">Where to put your code</a>. </span><span style="font-family: Arial, Helvetica, sans-serif;">As the title suggests, it's about which places are best for different types of code, based on their content. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">There are a number of options; conceptual at the entity or field level, locally at the entity or field level, within the component, a local procedure or a global procedure. All of these have their merits. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I've posted <a href="http://unifaceinfo.com/where-to-put-your-code/#comment-10929" target="_blank">my response</a>, defending the mighty global procedure, but why don't you have a read and add your opinion in the comments?</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Check out this blog post... <a href="http://unifaceinfo.com/where-to-put-your-code" target="_blank">http://unifaceinfo.com/where-to-put-your-code</a></span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com1tag:blogger.com,1999:blog-4660860057360911677.post-81441822483476634572015-06-29T18:09:00.000+01:002015-06-29T18:09:01.052+01:00WCG Online<span style="font-family: Arial, Helvetica, sans-serif;">I must apologise, this is not a Uniface-related post. That said, please read on!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />World Community Grid enables anyone with a computer, smartphone or tablet to donate their unused computing power to advance cutting-edge scientific research on topics related to health, poverty and sustainability. Through the contributions of over 650,000 individuals and 460 organizations, World Community Grid has supported 24 research projects to date, including searches for more effective treatments for cancer, HIV/AIDS and neglected tropical diseases. Other projects are looking for low-cost water filtration systems and new materials for capturing solar energy efficiently.<br /><br />Active projects include... </span><div>
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Outsmart Ebola Together</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Uncovering Genome Mysteries</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Mapping Cancer Markers</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">The Clean Energy Project - Phase 2</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">FightAIDS@Home.</span></li>
</ul>
<span style="font-family: Arial, Helvetica, sans-serif;"><div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
If you're not already a member, you can <a href="https://www.google.com/url?q=https://www.google.com/url?q%3Dhttp://www.worldcommunitygrid.org/reg/viewRegister.do?recruiterId%253D959887%26sa%3DD%26usg%3DAFQjCNGBrlsaYuxFj6532Llbk1xNbKfr7w&sa=D&usg=AFQjCNGlaWrk2pw6M9v9iohLEIuy2Rww_w">sign up here</a>.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">I have just launched a companion site; <a href="http://wcg.onl/" target="_blank">WCG Online</a>...</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/U2dQ4p46NuERhoRdHKtQfkswl1-NJNJJoRFS7QGlX9xV6kqO9Bu5uG4Yger0wn-qAK8=h900-rw" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://2.bp.blogspot.com/U2dQ4p46NuERhoRdHKtQfkswl1-NJNJJoRFS7QGlX9xV6kqO9Bu5uG4Yger0wn-qAK8=h900-rw" width="400" /></a></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">This s</span><span style="font-family: Arial, Helvetica, sans-serif;">ite is designed to give you, a valued member of the community, access to some more detailed statistics, as well as some lovely pretty graphs. It requires for username and a verifcation code, in order to fetch the relevant data. Nothing is stored on my server, all data is stored in your brower's local or session storage. This is then used to notify you of new milestones, such as badges earned. It allows you to rename and hide devices, so if you've got multiple devices (two phones, a tablet, etc) you can give them more easily identifiable names, or hide them completely from the other pages.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The site is also designed to be fully responsive and mobile friendly, created from the ground up in <a href="https://jquerymobile.com/" target="_blank">jQuery Mobile</a>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The next part of the project is to create custom widgets that you can link to on your own site. The offical site has widgets, but they use iframes and are rather basic. So I'm hoping to create images, and give a lot more flexiblity. Watch for those coming soon to </span><a href="http://wcg.onl/" style="font-family: Arial, Helvetica, sans-serif;" target="_blank">WCG Online</a>.<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">There is also a <a href="https://play.google.com/store/apps/details?id=wear360.wcg.onl" target="_blank">Play store</a> app, which provides a shortcut to the website, and is free to download, if you're interested.</span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-50476126211843018632015-05-02T11:18:00.000+01:002015-05-02T11:18:00.423+01:00Performance of getitem<span style="font-family: Arial, Helvetica, sans-serif;">I've previously posted about how <a href="http://uniface.blogspot.co.uk/2012/08/scanning-is-slow.html" target="_blank">scanning is slow</a>, and I stand by that. But I've recently discovered that in some situations, it can be less slow than using <b>getitem</b>. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I was doing a code review of some old code and found that it was using <b>$scan</b> in a situation where I thought you'd usually use <b>getitem</b>, and wondered why someone would have done it this way. But before I replaced it, I wanted to check the performance to see what difference I would be making by changing it, and I was surprised by the results!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The code was designed to check if a variable matched one of a reasonably large number of items. For this example, if stuck with 10 items...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TWO" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"THREE"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"FOUR" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"FIVE" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"SIX"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"SEVEN" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"EIGHT" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"NINE"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TEN" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">endif</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I could have used a <a href="http://uniface.blogspot.co.uk/2012/09/splitting-long-lines-of-code.html" target="_blank">line continuation marker</a>, but you get the idea.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">What the developer had done is replaced this set of conditions with a single <b>$scan</b>, like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> list = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"|ONE|TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT|NINE|TEN|"</span><span style="font-family: 'Courier New'; font-size: 10pt;"><br />
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">$scan</span><span style="font-family: 'Courier New'; font-size: 10pt;">(list,</span><span style="color: purple; font-family: 'Courier New'; font-size: 13.3333330154419px;">"|%%temp%%%|"</span><span style="font-family: 'Courier New'; font-size: 10pt;">) > 0 )</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition<o:p></o:p></span></div>
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-GB; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-GB; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">endif</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Note that this is not a Uniface list, a "bar" or "pipe" character has been used as the delimiter - this is placed at the beginning and end of the value to ensure it is not found as a sub-part of another longer value. It This takes up a lot less space, and is perfectly readable, but I was concerned about performance. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">To test this, I wanted to make sure it was fair, so I decided to always check both the first and the last item in the list in each iteration. I also wanted to test in a few different ways, and I came up with 4...</span><br />
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<span style="font-family: Arial, Helvetica, sans-serif;">1) </span><b style="font-family: Arial, Helvetica, sans-serif;">Set of conditions</b><br />
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TWO" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"THREE"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"FOUR" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"FIVE" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"SIX"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"SEVEN" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"EIGHT" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"NINE"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TEN" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">endif<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TEN"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TWO" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"THREE"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"FOUR" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"FIVE" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"SIX"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"SEVEN" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"EIGHT" </span><span style="font-family: 'Courier New'; font-size: 10pt;">| temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"NINE"
</span><span style="font-family: 'Courier New'; font-size: 10pt;">|
temp = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TEN" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">endif</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">2) </span><b style="font-family: Arial, Helvetica, sans-serif;">$scan a bar delimited string</b><br />
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> list = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"|ONE|TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT|NINE|TEN|"</span><span style="font-family: 'Courier New'; font-size: 10pt;"><br />
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">$scan</span><span style="font-family: 'Courier New'; font-size: 10pt;">(list,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"|ONE|"</span><span style="font-family: 'Courier New'; font-size: 10pt;">) > 0 )</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">endif<br />
</span><span style="font-family: 'Courier New'; font-size: 10pt;"> list = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"|ONE|TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT|NINE|TEN|"</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">
if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">$scan</span><span style="font-family: 'Courier New'; font-size: 10pt;">(list,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"|TEN|"</span><span style="font-family: 'Courier New'; font-size: 10pt;">) > 0 )<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"><span style="color: green;"> </span></span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">endif</span></div>
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<span style="font-family: Arial, Helvetica, sans-serif;">3) </span><b style="font-family: Arial, Helvetica, sans-serif;">getitem/id a Uniface list</b><br />
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> list = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE·;TWO·;THREE·;FOUR·;FIVE·;SIX·;SEVEN·;EIGHT·;NINE·;TEN"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">getitem</span><span style="font-family: 'Courier New'; font-size: 10pt;">/id temp,list,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: red; font-family: "Courier New"; font-size: 10.0pt;">$status </span><span style="font-family: 'Courier New'; font-size: 10pt;">> 0 )<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">endif<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">list = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE·;TWO·;THREE·;FOUR·;FIVE·;SIX·;SEVEN·;EIGHT·;NINE·;TEN"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">getitem</span><span style="font-family: 'Courier New'; font-size: 10pt;">/id temp,list,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TEN"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: red; font-family: "Courier New"; font-size: 10.0pt;">$status </span><span style="font-family: 'Courier New'; font-size: 10pt;">> 0 )<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">endif</span></div>
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<span style="font-family: Arial, Helvetica, sans-serif;">4) </span><b style="font-family: Arial, Helvetica, sans-serif;">$item a Uniface list</b><br />
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> list = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE·;TWO·;THREE·;FOUR·;FIVE·;SIX·;SEVEN·;EIGHT·;NINE·;TEN"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">$item</span><span style="font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,list) != </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">endif<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">list = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ONE·;TWO·;THREE·;FOUR·;FIVE·;SIX·;SEVEN·;EIGHT·;NINE·;TEN"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">$item</span><span style="font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TEN"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,list) != </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;testing condition</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">endif</span></div>
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b>
<span style="font-family: Arial, Helvetica, sans-serif;">I wasn't really sure what I was expecting, but I thought the <b>$scan</b> would be the worst performance. I tested over 2,000,000 iterations, and here's what I got...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">1) Set of conditions: 37.30, 36.95, 37.83 = 37.36 secs</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">2) <b>$scan</b> a bar delimited string: 21.76, 21.97, 21.24 = 21.66 secs</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">3) <b>getitem/id</b> a Uniface list: 24.46, 24.22, 24.89 = 24.52 secs</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">4) <b>$item</b> a Uniface list: 22.65, 23.25, 23.47 = 23.12 secs</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">So the slowest was the set of conditions. I didn't test it, but knowing that <a href="http://uniface.blogspot.co.uk/2012/05/are-if-statements-breaking-or-non.html" target="_blank">if statements shortcut</a> I figure that if the item was always passing the first condition it would be quick, but because half of my test items were only passing the last condition, it would have to check each of the conditions in the set before it passed.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Although there wasn't a big difference, what surprised me is that the <b>getitem/id</b> and <b>$item</b> were actually slower than the <b>$scan</b> in this case. I then remembered back to a <a href="http://lists.umanitoba.ca/pipermail/uniface-l/2008-September/003652.html" target="_blank">conversation on the Uniface-L mailing list</a>, which talked about how Uniface handles lists in the background. The description there indicates that an array is built in the background, which means there is an upfront cost for calling <b>getitem/id</b> (or <b>$item</b>) once, but then if you're looping through it is much quicker to access the rest, because the array can be used. However, because I'm rebuilding the list each time, that means the array needs to be rebuilt each time. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This means that actually <b>$scan</b> can be used to improve the performance when checking that an item is in a list, as long as you're only checking this list once and it's not going to be re-used. I expect there to be a point at which the number of times the list is re-used means that using <b>getitem/id</b> (or <b>$item</b>) would become better for performance.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Also, I've not tested different lengths of lists. However, given the results and my reasoning for why the results ended up this way, I would have thought extending the list would simply emphasize the results.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Checking if an item is in a list can be done a number of ways, and if it's being done a lot of times, performance can be eeked out by using a <b>$scan</b>, surprisingly!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com2tag:blogger.com,1999:blog-4660860057360911677.post-52311067798289687932015-04-11T13:39:00.000+01:002015-04-11T13:39:00.423+01:00Modernising the client application - icons in the menu<span style="font-family: Arial, Helvetica, sans-serif;">A lot of the Uniface development that I do these days is actually web development, which means I spend a lot of time with Javascript and JQuery, and less time with Uniface procscript. However, we still have client applications as well, and they can look tired and dated, so anything we can do to make them look more modern, can be a big win!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is a simple little trick that appeared in Uniface 9.6. It's actually been around for a while in dropdown menus, first as an undocumented feature, and then documented in Uniface 9.5 - I wrote <a href="http://uniface.blogspot.co.uk/2012/05/undocumented-feature-images-in.html" target="_blank">a blog post on this</a> almost three years ago. However, the same trick now works in menus.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">You can reference images in the menu items like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfuPpVxRnfWi48sW2AJ_EgF3YCBjno93xxeq8CBJqABRZ63yQ7rQhiporZyhZdq9899DCMmgQwN9C51B450GGEbV-f1oMwTGFbinopphkzRTsfMFtdT7VHFKDagBUCtKd65sDbXUdDcFI/s1600/code.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfuPpVxRnfWi48sW2AJ_EgF3YCBjno93xxeq8CBJqABRZ63yQ7rQhiporZyhZdq9899DCMmgQwN9C51B450GGEbV-f1oMwTGFbinopphkzRTsfMFtdT7VHFKDagBUCtKd65sDbXUdDcFI/s1600/code.png" height="296" width="400" /></a></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">You might not be able to read the image clearly, so the three menu items are...</span><br />
<br />
<ol>
<li><span style="font-family: Arial, Helvetica, sans-serif;">^U_REM_SELECT·!Cu%t</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">^U_SAVE·!Copy</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">^U_INS_SELECT·!Paste</span></li>
</ol>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">In this case, the image is at the start, with a gold-not (or gold-exclamation-mark) as a delimiter, and the menu item text after that.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">This appears in the client application this this...</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiajC4lu8VVwaSaGUBMRxf1mN0AjgxtDTRCDR8aeZr7ZyqX4zHOPH3oGyne7JupFcjhuLADc7S_OZeun9QjruXKw0IbKAWgjpVrfVdT2WgUT3VT3LA17WB2fGxG5uWXc8RalfSNTrgJTGI/s1600/menu.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiajC4lu8VVwaSaGUBMRxf1mN0AjgxtDTRCDR8aeZr7ZyqX4zHOPH3oGyne7JupFcjhuLADc7S_OZeun9QjruXKw0IbKAWgjpVrfVdT2WgUT3VT3LA17WB2fGxG5uWXc8RalfSNTrgJTGI/s1600/menu.png" height="127" width="400" /></a></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">As you can see - lovely icons! Please note that you would need these glyphs in your system for it to work, these are not provided as part of Uniface itself. </span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">You can include icons in one of two ways...</span></div>
<div>
</div>
<br />
<ul style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;"><b>^glyph</b> - glyphs need to be compiled into UOBJ (always available and performs well).</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;"><b>@filename</b> - images loaded from a fileserver (not always available and performs badly).</span></li>
</ul>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">I would recommend the glyph option though, for performance and reliability.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">You may also note that the percent character (%) can be used to denote which character should work when traversing the menu using the "Alt" key. If you do not explicitly denote this, the first character will be used.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">This is documented in the "Defining and Using Menus" section of the manuals, but can be hard to find unless you know what you're looking for! It's worth reading this for more information though.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: It's possible to make the client application look a little more modern now by including icons in the menu bars.</span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com1tag:blogger.com,1999:blog-4660860057360911677.post-41778327541696119362015-04-09T19:58:00.000+01:002015-04-10T08:38:01.971+01:00Undocumented feature - current assignment file<span style="font-family: Arial, Helvetica, sans-serif;">One great feature of Uniface is it's great flexibility and configurability, through the use of different assignment (.asn) files. These are used to define paths to the different runtime files and server locations, etc. The problem can then come though, especially with multiple environments, that you don't know which assignment file you're using!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I wrote a post a while ago about the <a href="http://uniface.blogspot.co.uk/2012/09/undocumented-feature-assignment-files.html" target="_blank">undocumented <b>$assignments</b> function</a>, which allows you to get access to the assignment file settings that you are currently using, but this doesn't help you get to the filename itself.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">One suggestion I've seen before is to add a logical to each assignment file which specifies the name/location of the file. However, it's way too easy for someone to move, copy or rename the file and neglect to update the logical, and then worse than not knowing, you think you do know but the information you're being given is inaccurate.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Luckily Uniface 9.6.06 has solved this problem with a new undocumented feature of <b>$processinfo</b>...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="MsoNormal">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;"> putmess $processinfo</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">(</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"cmdline"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">)</span><o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This will put the command line used to access the application into the message buffer. For example...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="MsoNormal">
<span style="font-family: "Courier New"; font-size: 8.5pt; line-height: 115%;"> "\\server\location\uniface\bin\uniface.exe"
/asn=</span><span style="font-family: 'Courier New'; font-size: 11.3333330154419px; line-height: 13.033332824707px;">\\server\location</span><span style="font-family: "Courier New"; font-size: 8.5pt; line-height: 115%;">\adm\uclidev.asn /ini=</span><span style="font-family: 'Courier New'; font-size: 11.3333330154419px; line-height: 13.033332824707px;">\\server\location</span><span style="font-family: "Courier New"; font-size: 8.5pt; line-height: 115%;">\ini\me.ini APPSHELL</span><o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">As you can see, the assignment file and ini file are both specified in the command line, along with the application shell as well. This should give you all the information you need, although you'll need to do some string manipulation to pull out the bit(s) you want.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This was recently discussed on the <a href="http://unifaceinfo.com/forum/uniface9/get-current-asn-file-name/" target="_blank">UnifaceInfo.com forums</a>, so you can check there for more context, and sign up if you haven't already!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: You can access the current assignment file location, but accessing the command line, as long as you're happy to use an undocumented/unsupported feature.</span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-16005661999792414082015-03-30T18:58:00.000+01:002015-03-30T18:58:00.051+01:00Indirection with dollar registers<span style="font-family: Arial, Helvetica, sans-serif;">Indirection in Uniface is a wonderful thing. You can populate a local/component/global variable with a field name, and then use indirection to get the field value of the field that the variable references. You can also use it to set the referenced field to a value, like this...</span><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"><br /></span>
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">fld1 = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"fld2"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="font-family: 'Courier New'; font-size: 10pt;">@fld1 = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Test"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( fld2 = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Test" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;this will be true</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">endif</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In this example, using the "@" character to indicate indirection, it's the field which is referenced by "fld1" and not "fld1" itself which is updated.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">You can even do <a href="http://theunifaceuniverse.blogspot.co.uk/2013/04/recursive-indirection.html" target="_blank">recursive indirection</a>, which is very cool! Not something I've had a need for myself, but very clever all the same.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">However, today I was trying to populate a register the same way, using code something like this...</span><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"><br /></span>
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">reg50 = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"$50"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="font-family: 'Courier New'; font-size: 10pt;">@reg50 = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Test"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( $50 = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Test" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;this will be false!</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">endif</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In this example, the register was still blank (or whatever the register was before hitting this code).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">To be fair, this is clearly stated in the Uniface manuals...</span><br />
<br />
<blockquote class="tr_bq" style="margin: 0cm 0cm 0.0001pt 36pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-GB;">Only fields can be
referenced indirectly; the name reached by the indirect reference cannot be a
variable. The following example is incorrect because the indirection refers to
a general variable rather than to a field:<br /> </span><span lang="EN-US" style="font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-GB;"></span></blockquote>
<br />
<blockquote class="tr_bq" style="margin: 0cm 0cm 0.0001pt 36pt;">
<span lang="EN-US" style="font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-GB;">$1 =
"$99"</span></blockquote>
<br />
<blockquote class="tr_bq" style="margin: 0cm 0cm 0.0001pt 36pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">@$1 =
"This string does not go to $99."</span></blockquote>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">But I still wanted to be able to set registers in an indirect way, so I came up with this alternative...</span><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"><br /></span>
<span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">putitem</span><span style="font-family: 'Courier New'; font-size: 10pt;">/id list,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"$50"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Test"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">getlistitems</span><span style="font-family: 'Courier New'; font-size: 10pt;">/id list</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( $50 = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Test" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;this will be true</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">endif</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This works by populating a list with the register and the value, and then uses <b>getlistitems</b> to populate them. The "/id" mode copies items from the associative list into one or more fields, or registers in this case.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">For example, you could use a simple <b>for</b> loop to clear out all of the dollar registers...</span><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><br /></span>
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> for </span><span style="font-family: 'Courier New'; font-size: 10pt;">count = 1 to 99<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">putitem</span><span style="font-family: 'Courier New'; font-size: 10pt;">/id list,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"$%%count%%%"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">""<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> endfor</span></div>
<div class="MsoNormal">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;"> getlistitems</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">/id list</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;"><o:p></o:p></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This would set each of the 99 dollar registers to blank.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Indirection works great for fields, but not for registers - however, you can use <b>getlistitems</b> to achieve the same outcome.</span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-60832850054817149212014-11-25T21:41:00.000+00:002014-11-25T21:41:00.231+00:00Syntax strings in different modes<span style="font-family: Arial, Helvetica, sans-serif;">Earlier I wrote a post about <a href="http://uniface.blogspot.com/2014/11/syntax-strings-versus-literal-strings.html" target="_blank">syntax strings versus literal strings</a>, which involved me diving into the Uniface manuals to check my facts. I talked about using <b>$syntax</b> to convert a literal string into a syntax string - very useful! </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">However, what I didn't know before was that you can have different modes. This is something that appears to have been added in Uniface 9.4.01, without me noticing.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">There's a lovely table in the Uniface manuals to describe them, but I've tested their examples and I think there are some inaccuracies. So I'm going to try and lay them out for you here...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><u>Classic</u></b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b><u><br /></u></b></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is the default behaviour, but is also represented by '%[X]'. In this case, the usual pattern matching rules apply, with syntax codes being used as wildcards to represent patterns of characters.</span><br />
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Proc code: </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$syntax</span><span style="font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"D&G"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Syntax string: </span><span style="font-family: Courier New, Courier, monospace;">'%[X]%D&G'</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Matches: "DOG", "DIG", "DUG", etc.</span></li>
</ul>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">You can see the syntax string starts with the mode defined in this case, which is optional for classic mode, because this is the default.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><u>Case Sensitive</u></b></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><u><br /></u></b></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">In this mode, all characters will only match with characters of the same case. Also, syntax codes will be treated as their literal characters, and not as wildcards.</span></div>
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Proc code: </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$syntax</span><span style="font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"D&G"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"CS"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<o:p></o:p></div>
</li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Resulting syntax string: </span><span style="font-family: Courier New, Courier, monospace;">'%[CS]D%&G%[X]'</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Matches: "D&G"</span></li>
</ul>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">You can see the syntax string starts with the mode defined in this case, but it also ends with the exit mode, switching back to the default/classic mode.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">The manuals suggest that in the proc code the mode is passed in without the double quotes, but I found this had to be a string for it to work. They also suggest that the mode "S" can be used instead of "CS" for the same thing - I found that only "CS" works in proc code, but you can use '%[CS]' or '%[S]' in syntax strings you write yourself.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<br />
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><u>Case Insensitive</u></b></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><u><br /></u></b></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">In this mode, all characters will match with characters of either upper or lower case. Again, syntax codes will be treated as their literal characters, and not as wildcards.</span></div>
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Proc code: </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$syntax</span><span style="font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"D&G"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"CI"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<o:p></o:p></div>
</li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Resulting syntax string: </span><span style="font-family: Courier New, Courier, monospace;">'%[CI]D%&G%[X]'</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Matches: "D&G", "d&g", "D&g" and "d&G"</span></li>
</ul>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Again, I had to use a string to define the mode in the proc code, and only "CI" worked, but </span><span style="font-family: Arial, Helvetica, sans-serif;">'%[CI]' and '%[I]' both worked in syntax strings I wrote myself.</span></div>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><u>NLS Locale</u></b></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><u><br /></u></b></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">In this mode, all characters will match with characters of either upper or lower case, depending on the National Language Support (NLS) locale that the system is in (can be checked or set using <b>$nlslocale</b>). Again, syntax codes will be treated as their literal characters, and not as wildcards.</span></div>
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Proc code: </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$syntax</span><span style="font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"i#B"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"NLS"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<o:p></o:p></div>
</li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Resulting syntax string: </span><span style="font-family: Courier New, Courier, monospace;">'%[NLS]i%#B%[X]'</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Matches: If your local is Turkish (tr_TR) then "i#B" and "İ#b", but not "I#B"</span></li>
</ul>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Once more, I had to use a string to define the mode in the proc code, and only "NLS" worked, but </span><span style="font-family: Arial, Helvetica, sans-serif;">'%[NLS]' and '%[N]' both worked in syntax strings I wrote myself.</span></div>
</div>
<div>
<br /></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><u>Mixing modes</u></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">You can also define a combination of modes in a single pattern, something like this...</span></div>
<div>
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Proc code: </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$syntax</span><span style="font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"%[CI]D%&%[CS]G%[X]"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<o:p></o:p></div>
</li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Resulting syntax string: </span><span style="font-family: Courier New, Courier, monospace;">'%<span style="font-family: 'Courier New';">[C</span><span style="font-family: 'Courier New'; font-size: 13.3333330154419px;">I]D%&%[CS]G%[X]</span><span style="font-size: x-small;">'</span></span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Matches: "D&G" and "d&G"</span></li>
</ul>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">There's a slight typo in the manuals with the proc code here, as they have missed the "%" from the beginning! </span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: You can use different modes in syntax strings, either specifying the case-sensitivity or relying on the NLS locale, but be careful if you're using <b>$syntax</b> because you'll lose the wildcards.</span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-24660688071646442312014-11-24T18:12:00.000+00:002014-11-24T18:12:00.366+00:00Syntax strings versus literal strings<span style="font-family: Arial, Helvetica, sans-serif;">There are a number of very important differences between syntax strings and literal strings, which I will attempt to highlight for you here.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Firstly, the Uniface definition of a syntax string...</span><br />
<blockquote class="tr_bq">
<span style="font-family: Arial, Helvetica, sans-serif;"><i>Uniface enables you to determine if the data in a string value matches a desired pattern using syntax strings. A syntax string is a group of characters and syntax codes enclosed in single quotation marks (').</i></span></blockquote>
<span style="font-family: Arial, Helvetica, sans-serif;">So that's the first big difference right there, literal strings are in double quotes (") and syntax strings are in single quotes (')...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">literalString = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Literal string"</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">syntaxString
= 'Syntax string'</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">A syntax string is used for pattern matching, but they are much more simplistic than the regular expressions that you might be used to in other languages. The syntax codes are quite straight forward...</span><br />
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: red;">#</span></b> - one digit (0-9)</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: red;">&</span></b> - one letter (A-Z, a-z)</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: red;">@</span></b> - one letter, digit or underscore (A-Z, a-z, 0-9, _)</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: red;">~&</span></b> - one extended letter</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: red;">~@</span></b> - one extended letter, digit or underscore</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: red;">?</span></b> - one ASCII character</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: red;">A</span>-<span style="color: red;">Z</span></b> - that letter, in uppercase</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: red;">a</span>-<span style="color: red;">z</span></b> - that letter, in uppercase or lowercase</span></li>
</ul>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">On top of these are a few other syntax codes of note...</span><br />
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">If you want to search for the literal version of a syntax code, eg. you want to search for the hash character (#) not a digit (0-9), then you can escape the syntax code using <b style="color: red;">%</b> before it. Therefore, to search for a hash character it would be '%#' and to search for a percentage character it would be '%%'.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">If you want to search for a unknown number of syntax code, eg. you want to search for 2 or more digits, then you can use <b><span style="color: red;">*</span></b> after it. Therefore, to search for 2 or more digits it would be '###*' - in this case the first two hash characters represent one digit each, and the third hash character is part of the the syntax code '#*', which means zero or more (0-n) digits.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">If you want part of the pattern to be optional (to match the pattern or blank) then you can put rounded brackets around it, using <b><span style="color: red;">(</span></b> and <b><span style="color: red;">)</span></b>. For example, '##(#)' would match with 2 or 3 digits (but not more than 3).</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Any other ch</span><span style="font-family: Arial, Helvetica, sans-serif;">aracter is treated literally as that character. </span></li>
</ul>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Uniface also gives a handy function that can be used to convert a literal string into a syntax string, sensibly named</span><b style="font-family: Arial, Helvetica, sans-serif;"> $syntax</b><span style="font-family: Arial, Helvetica, sans-serif;">...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;"> </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">syntaxString
= </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">$syntax</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">(</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"Literal
string"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">)</span><o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This can be especially useful if you're storing the pattern in the database, or some other configuration.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here are a few examples from the Uniface manuals...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-cellspacing: 0cm; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; mso-yfti-tbllook: 1184;" summary="">
<thead>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 67.0%;" valign="top" width="67%">
<div class="MsoNormal">
<b><span style="font-family: "Arial","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-GB;">Proc
with Syntax String <o:p></o:p></span></b></div>
</td>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 32.0%;" valign="top" width="32%">
<div class="MsoNormal">
<b><span style="font-family: "Arial","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-GB;">Result
<o:p></o:p></span></b></div>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 67.0%;" valign="top" width="67%">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">('#'</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;"> "123"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">if</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;"> </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">('#*'</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">
</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">=</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;"> "123"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">)</span><o:p></o:p></div>
</td>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 32.0%;" valign="top" width="32%">
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">FALSE<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: x-small;">TRUE </span><span style="font-size: 12pt;"><o:p></o:p></span></span></div>
</td>
</tr>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 67.0%;" valign="top" width="67%">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('#*'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">vValue)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('#*'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"%%vValue"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><o:p></o:p></div>
</td>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 32.0%;" valign="top" width="32%">
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">TRUE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: x-small;">TRUE </span><span style="font-size: 12pt;"><o:p></o:p></span></span></div>
</td>
</tr>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 67.0%;" valign="top" width="67%">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('&###'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"1234"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('@###'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"1234"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><o:p></o:p></div>
</td>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 32.0%;" valign="top" width="32%">
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">FALSE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: x-small;">TRUE </span><span style="font-size: 12pt;"><o:p></o:p></span></span></div>
</td>
</tr>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 67.0%;" valign="top" width="67%">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('?'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"A"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('??'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"A"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('??*'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"A"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('?'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ABC"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('??*'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ABC"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><o:p></o:p></div>
</td>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 32.0%;" valign="top" width="32%">
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">TRUE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">FALSE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">TRUE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">FALSE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: x-small;">TRUE </span><span style="font-size: 12pt;"><o:p></o:p></span></span></div>
</td>
</tr>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 67.0%;" valign="top" width="67%">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('(#(-))&&&'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"ABC"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('(#(-))&&&'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"1ABC"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('(#(-))&&&'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"1-ABC"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">('(#(-))&&&'</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">=</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"12ABC"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span><o:p></o:p></div>
</td>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 3.0pt 3.0pt 3.0pt 3.0pt; width: 32.0%;" valign="top" width="32%">
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">TRUE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">TRUE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">TRUE <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">FALSE </span><span style="font-family: Arial, sans-serif; font-size: 12pt;"><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<br />
<div class="MsoNormal">
<br /></div>
<span style="font-family: Arial, Helvetica, sans-serif;">I've had (occasionally heated!) discussions with developers before, when they have said that...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( myVar = </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Y" </span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;">...and...</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( myVar = 'Y' )</span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;">...are interchangable. </span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;">Yes, I can see that the pattern 'Y' only matches with the string "Y" and nothing else, but they are entirely different ideas, and should not be used interchangeably. If you want to only match with "Y", then use the literal string "Y", because that's what you mean. </span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;">In my experience, developers who say that these are interchangable are developers who don't understand what the differences are.</span></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Syntax strings are very useful for pattern matching, but very different than literal strings. Know the difference, and know when to use which.</span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-35132956587804687352014-10-23T17:16:00.001+01:002014-10-23T17:16:47.532+01:00Fetching web content<span style="font-family: Arial, Helvetica, sans-serif;">I've been working on fetching web content recently, mostly for building authentication workflows, using the likes of <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">Facebook</a> and <a href="https://developers.google.com/accounts/docs/OAuth2WebServer" target="_blank">Google</a> to act as authentication services. I'm going to go into detail about how I've done those, not in this post at least, but more simply how I made the requests from my Uniface service form, out to those external services. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">There are a number of different <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html" target="_blank">HTTP methods</a>. Generally speaking, when you are retrieving data only then the method is "GET", whereas if you are sending data that may perform an action as well then the method is "POST". There are others, but I'm going to stick with these two for now, as they are more commonly used.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In fact, I'm going to start with "GET" first. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The first thing you need to do is consider the character set. Your system may be set in different character sets, but you need to make sure the character set of your request matches the service you are calling, in my case it was UTF-8...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">vCharSet = </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$sys_charset <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">;backup current setting for later</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;"><span style="color: green;"> </span></span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">$sys_charset </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">= </span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">"UTF8" </span><o:p></o:p><span style="color: green; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">;set to the character set we need</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">We then want to create a new instance of the "UHTTP" component - this is the Uniface component that is going to do most of the hard work for us...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">newinstance </span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"UHTTP"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,vHandle<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: red; font-family: 'Courier New'; font-size: 10pt;">$status </span><span style="font-family: 'Courier New'; font-size: 10pt;">< 0 & </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$procerror </span><span style="font-family: 'Courier New'; font-size: 10pt;">< 0</span><span style="font-family: 'Courier New'; font-size: 10pt;"> )</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$sys_charset </span><span style="font-family: 'Courier New'; font-size: 10pt;">= vCharSet</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;restore character set</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">return </span><span style="font-family: 'Courier New'; font-size: 10pt;">-101 <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;error handling!</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;"><span style="color: green;"> </span></span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">endif</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Once you've got your instance, the next step is to define how the component responds to mismatched or expired certificates, and how it calculates the content length. By default it will error if there is a certificate error and you have to manually calculate the content length yourself. It's a binary switch, so to switch them all off we do the following...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">activate </span><span style="font-family: 'Courier New'; font-size: 10pt;">vHandle.SET_FLAGS(7)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: red; font-family: 'Courier New'; font-size: 10pt;">$status </span><span style="font-family: 'Courier New'; font-size: 10pt;">< 0 & </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$procerror </span><span style="font-family: 'Courier New'; font-size: 10pt;">< 0</span><span style="font-family: 'Courier New'; font-size: 10pt;"> )</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$sys_charset </span><span style="font-family: 'Courier New'; font-size: 10pt;">= vCharSet<o:p></o:p></span><span style="font-family: 'Courier New'; font-size: 10pt;"> <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;restore character set</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">return </span><span style="font-family: 'Courier New'; font-size: 10pt;">-102<o:p></o:p></span><span style="font-family: 'Courier New'; font-size: 10pt;"> <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;error handling!</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;"><span style="color: green;"> </span></span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">endif</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">We're now ready to make the request. In this example, I'm just going to grab the Google homepage...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">activate </span><span style="font-family: 'Courier New'; font-size: 10pt;">vHandle.SEND(</span><span style="color: purple; font-family: 'Courier New'; font-size: 13.3333330154419px;">"http://www.google.co.uk"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"GET"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">""</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">""</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: 'Courier New'; font-size: 13.3333330154419px;">""</span><span style="font-family: 'Courier New'; font-size: 10pt;">,vContent,vResponse)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: red; font-family: 'Courier New'; font-size: 10pt;">$status </span><span style="font-family: 'Courier New'; font-size: 10pt;">< 0 & </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$procerror </span><span style="font-family: 'Courier New'; font-size: 10pt;">< 0</span><span style="font-family: 'Courier New'; font-size: 10pt;"> )</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$sys_charset </span><span style="font-family: 'Courier New'; font-size: 10pt;">= vCharSet<o:p></o:p></span><span style="font-family: 'Courier New'; font-size: 10pt;"> <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;restore character set</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">return </span><span style="font-family: 'Courier New'; font-size: 10pt;">-103<o:p></o:p></span><span style="font-family: 'Courier New'; font-size: 10pt;"> <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;error handling!</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;"><span style="color: green;"> </span></span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">endif</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The parameters are:</span><br />
<br />
<ol>
<li><span style="font-family: Arial, Helvetica, sans-serif;">URL (string : in) - the URL you're sending the request to.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Method (string : in) - the method being used (this is not checked by "UHTTP").</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Username (string : in) - if you're using a secure URL, you may need to populate this.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Password (string : in) - again, you may need to populate this.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Headers (string : inout) - the HTTP request headers in and the response headers out.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Content (string : inout) - in the case of a "GET" this is out only and the page contents.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Response (string : out) - the HTTP response headers.</span></li>
</ol>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">The <b>$status</b> should be set to <b>200</b> for a successful response (to match the HTTP status code for success) or it may be set to <b>1</b>. If it is set to <b>1</b> then this means that the content was larger than the parameter limit (10Mb) and therefore you will need to get the rest of the content from the buffer, like this...</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">while </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: red; font-family: 'Courier New'; font-size: 13.3333330154419px;">$status</span><span style="font-family: 'Courier New'; font-size: 10pt;"> = 1 )<o:p></o:p></span></div>
<div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">activate </span><span style="font-family: 'Courier New'; font-size: 10pt;">vHandle.READ_CONTENT(vExtra)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">if </span><span style="font-family: 'Courier New'; font-size: 10pt;">( </span><span style="color: red; font-family: 'Courier New'; font-size: 10pt;">$status </span><span style="font-family: 'Courier New'; font-size: 10pt;">< 0 & </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$procerror </span><span style="font-family: 'Courier New'; font-size: 10pt;">< 0</span><span style="font-family: 'Courier New'; font-size: 10pt;"> )</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">$sys_charset </span><span style="font-family: 'Courier New'; font-size: 10pt;">= vCharSet<o:p></o:p></span><span style="font-family: 'Courier New'; font-size: 10pt;"> <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;restore character set</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">return </span><span style="font-family: 'Courier New'; font-size: 10pt;">-104 <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;error handling!</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">endif</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;"> vC</span><span style="font-family: 'Courier New'; font-size: 10pt;">ontent = </span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"%%vContent%%vExtra%%%"<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">endwhile</span></div>
</div>
<br />
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">You now have the full page contents, but don't forget to restore the character set...</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"> $sys_charset </span><span style="font-family: 'Courier New'; font-size: 10pt;">= vCharSet<o:p></o:p></span><span style="font-family: 'Courier New'; font-size: 10pt;"> <o:p></o:p></span><span style="color: green; font-family: 'Courier New'; font-size: 13.3333330154419px; line-height: 15.3333320617676px;">;restore character set</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Doing a "POST" is very similar, except for a couple of differences:</span></div>
<div>
<ol>
<li><span style="font-family: Arial, Helvetica, sans-serif;">To replicate a web browser "POST", which you are usually doing, you need to make sure the 5th parameter of the SEND call is populated with the following header.. </span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 15.3333320617676px;">"Content-Type=application/x-www-form-urlencoded"</span><div class="MsoNormal">
<o:p></o:p></div>
</li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">The 6th parameter of the SEND call needs to be populated with the data that you are sending in your request. If this is larger than 10Mb then you will need to have a WRITE_CONTENT loop (similar to the READ_CONTENT loop) before the SEND, in order to populate the buffer with the full contents.</span></li>
</ol>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">This all works rather well. However, I've found two major limitations along the way.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Firstly, it was not possible to send a request to a URL which had a colon (:) character after the protocol. For example, when trying to get a user's <a href="https://developer.linkedin.com/documents/authentication" target="_blank">LinkedIn</a> ID you would use the following URL...</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: 'Courier New'; font-size: 10pt;"> "https://api.linkedin.com/v1/people/~:(id)?oauth2_access_token=%%vToken%%%"<o:p></o:p></span></div>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">The colon (:) character after "/people/~" broke the URL. Luckily I'm using the past tense here, this was fixed in patch X504 (for Uniface 9.6.05). This works fine now we've installed the patch.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Secondly, the observant of you may have noticed the 6th parameter of the SEND call is defined as a <b>string</b>. This is great for grabbing HTML page source from a website, or even doing most webservice calls, as these tend to return either XML and JSON strings of data. However, it makes creating something like a <a href="https://www.dropbox.com/developers/reference/devguide" target="_blank">Dropbox</a> interface impossible, or at least very limited. You can grab text files, but nothing else! No images, no Office documents, no PDFs.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Unfortunately there's no word from Uniface on when this second issue might be resolved.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: It's possible to use the "UHTTP" component to request text data, either from a web page or a webservice. Just don't expect it to work with binary files, yet!</span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-62022953152602878352014-09-30T09:26:00.000+01:002014-09-30T09:26:24.810+01:00Rosetta Code<span style="font-family: Arial, Helvetica, sans-serif;">Recently I was pointed an interesting website, or at least, I thought it was interesting. And that's <a href="http://rosettacode.org/">Rosetta Code</a>. I'll let them describe what it's all about...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<blockquote class="tr_bq">
<span style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.2000007629395px;">Rosetta Code is a </span><a class="extiw" href="http://en.wikipedia.org/wiki/Chrestomathy" style="background: none rgb(255, 255, 255); color: #663366; font-family: sans-serif; font-size: 13px; line-height: 19.2000007629395px; text-decoration: none;" title="wp:Chrestomathy">programming chrestomathy</a><span style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.2000007629395px;"> site. The idea is to present solutions to the same task in as many different languages as possible, to demonstrate how languages are similar and different, and to aid a person with a grounding in one approach to a problem in learning another. </span></blockquote>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Surprise, surprise; Uniface was nowhere to be seen. So I've rectified that problem, and added <a href="http://rosettacode.org/wiki/Uniface">Uniface</a> to the <a href="http://rosettacode.org/wiki/Category:Programming_Languages">list of programming languages</a>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I didn't have a lot of time on my hands, so I cheated and copied the contents from <a href="http://en.wikipedia.org/wiki/Uniface_(programming_language)">Wikipedia</a>, in order to create the base page. Some of the content is out of date, as it still lists Uniface as a Compuware product, but it's a start.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The idea now is to go through and complete some of the <a href="http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_Uniface">tasks not yet implemented in Uniface</a>, which is currently all of them! I plan to devote a little bit of time to this myself, but I guess this is a bit of a call out to Uniface developers - go forth and complete tasks!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Rosetta Code looks like an interesting site for comparing different languages, but Uniface examples are non-existent.</span><br />
<blockquote class="tr_bq">
<span style="font-family: Arial, Helvetica, sans-serif;"> </span></blockquote>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com1tag:blogger.com,1999:blog-4660860057360911677.post-64650277951443862222014-09-03T12:49:00.001+01:002014-09-03T12:49:50.532+01:00New Uniface, a roadmap<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I read an interesting article today, so I thought I'd post a link...</span><br />
<br />
<h1 class="bottommarg" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: #577088; font-family: museo-slab, 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 34px; list-style: none; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizelegibility; vertical-align: baseline;">
<span style="font-size: large;">New Uniface, a roadmap</span></h1>
<h2 style="background-color: white; color: #5f5f5f; font-family: verdana, arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 10px; margin-top: 5px;">
<hr style="border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-left-width: 0px; border-right-width: 0px; border-top-color: orange; border-top-style: solid; color: #60666c; font-family: Arial, Helvetica, sans-serif; font-weight: normal; height: 1px; line-height: 19.2000007629395px; margin: 18px 0px; padding: 0px;" />
<div class="intro" style="background: rgb(239, 239, 239); border-bottom-color: rgb(110, 110, 110); border-bottom-style: dotted; border-top-color: rgb(110, 110, 110); border-top-style: dotted; border-width: 1px 0px; clear: both; color: #60666c; font-family: Arial, Helvetica, sans-serif; font-weight: normal; line-height: 19.2000007629395px; list-style: none; margin: 20px 0px 10px; outline: 0px; padding: 2px 5px 5px; vertical-align: baseline;">
<div class="itaFace" style="background: transparent; border: 1px solid rgb(128, 128, 128); float: left; height: 50px; list-style: none; margin: 3px 5px 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline; width: 40px;">
<a href="http://www.bloorresearch.com/about/people/David-Norfolk/" style="background: transparent; color: #f49d51; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline;"><img alt="Photo of David Norfolk" height="50" src="http://www.bloorresearch.com/assets/smallphoto/david-norfolk.gif" style="background: transparent; border: 0px; list-style: none; margin: 0px; max-width: 100%; outline: none; padding: 0px; vertical-align: middle;" title="David Norfolk" width="40" /></a></div>
<div class="itaHeadline" style="background: transparent; border: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; list-style: none; margin-top: 3px; outline: 0px; padding: 0px; vertical-align: baseline;">
<strong style="background: transparent; border: 0px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Written By:</strong> <span itemprop="author" itemscope="" itemtype="http://schema.org/Person" style="background: transparent; border: 0px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><span itemprop="name" style="background: transparent; border: 0px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><a href="http://www.bloorresearch.com/about/people/david-norfolk/" style="background: transparent; color: #f49d51; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline;" title="View profile for David Norfolk">David Norfolk</a></span></span><br /><strong style="background: transparent; border: 0px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Published:</strong> <span content="2014-09-03" itemprop="datePublished" style="background: transparent; border: 0px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">3rd September, 2014</span><br /><strong style="background: transparent; border: 0px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Content Copyright © 2014 <span itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization" style="background: transparent; border: 0px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><span itemprop="name" style="background: transparent; border: 0px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Bloor</span></span>. All Rights Reserved.</strong></div>
</div>
<div class="blog_body" itemprop="articleBody" style="background: transparent; border: 0px; color: #60666c; font-family: Arial, Helvetica, sans-serif; font-weight: normal; line-height: 19.2000007629395px; list-style: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">
</div>
</h2>
<span style="font-family: Arial, Helvetica, sans-serif;">Link to article: <a href="http://www.bloorresearch.com/blog/the-norfolk-punt/2014/9/new-uniface-a-roadmap/">http://www.bloorresearch.com/blog/the-norfolk-punt/2014/9/new-uniface-a-roadmap/</a></span><br />
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">This matches up pretty well with what I was told at a User Event back in January, but with the welcome addition of <b>Uniface 9.7</b> to the roadmap.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The main themes for <b>Uniface 10</b> are...</span><br />
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Advanced development environment (a brand new IDE, written in Uniface itself!)</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Agile development methodology</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Mobile deployment (dedicated team for mobile development)</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Cloud deployment (this will come later, not in 10.01 or 10.02)</span></li>
</ul>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">We'll have to wait until <b>Uniface 10.02</b> for a migration path from earlier versions though, which should be sometime next year.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Life after Compuware is still looking good for Uniface.</span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-87035179024871688442014-07-04T11:18:00.000+01:002014-07-14T10:40:59.649+01:00Generating random numbers (again)<span style="font-family: Arial, Helvetica, sans-serif;">A couple of years ago I wrote a post about <a href="http://uniface.blogspot.co.uk/2012/07/generating-random-numbers.html">generating random numbers</a>. I talked about three different ways of generating a random number (in absence of a <b>$random</b> function in Uniface)...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">1) Use a </span><b style="font-family: Arial, Helvetica, sans-serif;">perform</b><span style="font-family: Arial, Helvetica, sans-serif;"> to call a DLL (or shared object) that returns a random number.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">2) Use </span><b style="font-family: Arial, Helvetica, sans-serif;">$uuid</b><span style="font-family: Arial, Helvetica, sans-serif;"> to generate a random number in Uniface.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">3) Use a DIY </span><a href="http://en.wikipedia.org/wiki/Linear_congruential_generator" style="font-family: Arial, Helvetica, sans-serif;">Linear Congruential Generator</a><span style="font-family: Arial, Helvetica, sans-serif;">, built in Uniface.</span><br />
<br />
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">I found that the <b>perform</b> was the best for performance, and I also stated that it gave a better randomness as well, but I failed to back this up (sorry). </span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">This issue has raised it's head again, as we're currently trying to get rid of all our own external libraries (DLL/SO) in order to improve maintainability and interoperability.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">This time I'm going to test over 1,000,000 iterations (instead of 2,000,000 as before), as there's a little more code inside the loop to store the generated numbers. Each method will be generating numbers between 0 and 99, and I will then plot the number of times each of these numbers is generated, and report the standard deviation as well - this should give a good idea of the spread.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">1) <b>perform</b>: 35.98 seconds (0.036ms per value) - standard deviation: 28.870</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyovaywSUqT5G_3zCseIUwS6hK-fXmIrPez8ejSfdYGmf8-j34jjUJNIPpU7xXy0oqDnitha65oWsVLU012Iet15bPhBBFH0RIhZcaz_PotLT5_mEMWq8rKr3tu4-849ACLSUYHOF0K5o/s1600/perform.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyovaywSUqT5G_3zCseIUwS6hK-fXmIrPez8ejSfdYGmf8-j34jjUJNIPpU7xXy0oqDnitha65oWsVLU012Iet15bPhBBFH0RIhZcaz_PotLT5_mEMWq8rKr3tu4-849ACLSUYHOF0K5o/s1600/perform.png" height="215" width="400" /></a></div>
<div>
<br /></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">2) <b>$uuid</b>: </span><span style="font-family: Arial, Helvetica, sans-serif;">42.8 seconds (0.048ms per value) - standard deviation: 28.869</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC-MkL1VdbHsEafjOXUcISPsECzr5MsJN7ow0quAKEw5n3WKMuvEXPVV2ZFwH3i9xXCrCHbPtWOtm3WY6kKjGe1YLgxLT4pUkEzxVVMfoiKJ7ZPhrT9N-Asu8BBBYq3prsT4LPLmQgcIo/s1600/guid.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC-MkL1VdbHsEafjOXUcISPsECzr5MsJN7ow0quAKEw5n3WKMuvEXPVV2ZFwH3i9xXCrCHbPtWOtm3WY6kKjGe1YLgxLT4pUkEzxVVMfoiKJ7ZPhrT9N-Asu8BBBYq3prsT4LPLmQgcIo/s1600/guid.png" height="213" width="400" /></a></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">3) DIY: 56.54 seconds (0.057ms per value) - standard deviation: 28.894</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMy45UmU2f46MP37VvIIa71ldHFA_4mJv_sqmIkVaGaoUvrq8KmEsggdnnTEyRAtABZK-5njWFPcd4FU2I-7byxft2HKt4LrlDsYg4Ll8XcrG_2vpOcIZoT3PW8f0daydFNeGiykJEqGU/s1600/linear.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMy45UmU2f46MP37VvIIa71ldHFA_4mJv_sqmIkVaGaoUvrq8KmEsggdnnTEyRAtABZK-5njWFPcd4FU2I-7byxft2HKt4LrlDsYg4Ll8XcrG_2vpOcIZoT3PW8f0daydFNeGiykJEqGU/s1600/linear.png" height="213" width="400" /></a></div>
<div>
<br /></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">As you can see from these charts, and the standard deviation of the numbers generated, all three of these methods have a similarly decent spread. The time difference hasn't been quite as drastic this time, although that's likely to be due to the extra code in the loop that stores the values for the spread analysis. Unless you're planning to generate a million random numbers, it's not likely to have a noticeable effect on performance though.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">One thing to note though, if you're only concerned with Windows environments, then you don't have a problem, and as long as your DLLs (or shared objects in Unix) are equivalent, then you don't have a problem. However, the <b>$uuid</b> method does <u>not</u> work as well in Unix environments...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">4) <b>$uuid</b> in Unix: (time is not comparable) - standard deviation: 28.833</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoVZxCy0UGe9L0m0c61LG9IzHa8kde_d2QX1r48kgzU2J63IUAIrk37EkqNgxR6TmQ1P9Fnn2T2Dr_4hlyp-q1JkS-FdjRGKyFs32nAcB0Tc-sbiK-rfTmMMkhNCqHCxOTNeGTzkLP8vc/s1600/unix.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoVZxCy0UGe9L0m0c61LG9IzHa8kde_d2QX1r48kgzU2J63IUAIrk37EkqNgxR6TmQ1P9Fnn2T2Dr_4hlyp-q1JkS-FdjRGKyFs32nAcB0Tc-sbiK-rfTmMMkhNCqHCxOTNeGTzkLP8vc/s1600/unix.png" height="211" width="400" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">As you can see, the spread is not uniform at all. This is because UUID is not sufficiently random in Unix - the first 5 characters seem to be time based, then 3 random characters, then the rest remains constant within the same userver (presumably based on the machine itself and the process ID). </span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: As before, </span><b style="font-family: Arial, Helvetica, sans-serif;">perform</b><span style="font-family: Arial, Helvetica, sans-serif;"> is the quickest method, but if you're supporting multiple environment configurations then it's likely that building your own random number generator (possibly using </span><b style="font-family: Arial, Helvetica, sans-serif;">$uuid</b><span style="font-family: Arial, Helvetica, sans-serif;"> on Windows</span><span style="font-family: Arial, Helvetica, sans-serif;">) is going to make your life much easier.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Additional: </span><span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 16.7999992370605px; text-align: justify;">There's now a blog post about this on Uniface.info, if you're interested... <a href="http://unifaceinfo.com/random-number-generator-uniface/">http://unifaceinfo.com/random-number-generator-uniface/</a></span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com0tag:blogger.com,1999:blog-4660860057360911677.post-29450983478011882622014-06-18T21:11:00.000+01:002014-06-18T21:11:31.714+01:00Converting a form to a service and vice versa<span style="font-family: Arial, Helvetica, sans-serif;">I discovered something new and rather interesting yesterday. And by new, I mean new to me, apparently it's been there "forever"!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I was trying to do some testing for my earlier post on <a href="http://uniface.blogspot.co.uk/2014/06/what-are-handles-and-should-i-be-using.html">handles</a>, and wanted to run an operation on a mapped server. However, the operation was on a form, and not a service, which it needs to be to run mapped. I was just about to create a new service and copy the operation code when I mentioned this off hand in conversation with a colleague of mine, and he mentioned that it was actually very easy to convert a form into a service.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I thought he was about to show me some really clever, well hidden little trick. Alas, it's right there in the "File" menu, and always has been...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUxhkJTh4IOmWMQy6-fTMtGSJOq4iK8y_P_zamqvGAFpldPuTCpBe08CUKePfK1VuGXQGR4_qTaGNiKgUoeV4GzhcIO2r6VGXGNBIxWcSLwQ3HDDcaFErpOxxmFyDYtVnnCUb7V74yinE/s1600/convert.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUxhkJTh4IOmWMQy6-fTMtGSJOq4iK8y_P_zamqvGAFpldPuTCpBe08CUKePfK1VuGXQGR4_qTaGNiKgUoeV4GzhcIO2r6VGXGNBIxWcSLwQ3HDDcaFErpOxxmFyDYtVnnCUb7V74yinE/s1600/convert.png" height="400" width="350" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">So all you have to do is click that and compile, job done! You learn something new every day.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: It's really easy to convert a form into a service, or many other things, and vice versa, which you might need to do if you want to run an operation on a mapped server.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Thanks to <i>Mark R</i> for pointing this out for me.</span>Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com2tag:blogger.com,1999:blog-4660860057360911677.post-24790062867556761832014-06-17T17:03:00.000+01:002014-06-17T17:03:03.704+01:00What are handles and should I be using them?<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, Helvetica, sans-serif;">The Uniface manuals describes a handle as...</span><br />
<blockquote class="tr_bq">
<span style="background-color: white;">A handle is a
reference to an ob</span>ject, such as a component instance, entity, occurrence, or
fie<span style="background-color: white;">ld. Handles can
be used to call operations on the referenced object, or to pass these objects as
variables and parameters</span>.</blockquote>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">If you're used to pointers, you may at first glance think that these are the same, but they're not. A pointer contains the address of an item in memory and is therefore fixed, whereas a handle is an abstract reference, which means the address can be changed without breaking the reference. This makes them very useful.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In Uniface you can have "public" or "partner" handles, which allow you to define which types of operations can access them. They are also datatypes available for local, component and global variables, depending on the scope required. I'm not going to discuss either of these points in detail, but I think it's handy to know.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">As the description in the manual states, you can create a handle that references most Uniface objects, and there are different methods for creating these handles: Component instances (<b>$instancehandle</b>), entity collections (<b>$colhandle</b>), entity occurrences (<b>$occhandle</b>), fields (<b>$fieldhandle</b>) and also OCX controls (<b>$ocxhandle</b>). </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I'm going to focus on component instances. </span><span style="font-family: Arial, Helvetica, sans-serif;">More specifically, I'm going to focus on creating new component instances, using </span><b style="font-family: Arial, Helvetica, sans-serif;">newinstance</b><span style="font-family: Arial, Helvetica, sans-serif;"> and handles. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">As you might expect, creating a new instance of a form has a little lead time. Using a handle doesn't stop this lead time, but what it does do, is mean that it only has to happen once. This means that using a handle for a single form activation is not going to give you any advantage (unless you just love handles!) but when calling operations on the same form multiple times, handles could give you a performance improvement.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is something like how you could <b>activate</b> a form...</span><br />
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">activate</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">
</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"TEST_FORM"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">.test_oper(</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"Test"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">)<o:p></o:p></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In fact this does an implicit <b>newinstance</b> as well (if it can't already find an instance with the same name as the form) and so explicitly your code could look like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">newinstance</span><span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"</span><span style="color: purple; font-family: 'Courier New'; font-size: 13px; line-height: 15.333332061767578px;">TEST_FORM</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"</span><span style="color: purple; font-family: 'Courier New'; font-size: 13px; line-height: 15.333332061767578px;">TEST_FORM</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">activate</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">
</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">"</span><span style="color: purple; font-family: 'Courier New'; font-size: 13px; line-height: 15.333332061767578px;">TEST_FORM</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">.</span><span style="font-family: 'Courier New'; font-size: 13px; line-height: 15.333332061767578px;">test_oper</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">(</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">"Test"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">)</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">If you were to replace this with a handle then you may use something like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> newinstance</span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"</span><span style="color: purple; font-family: 'Courier New'; font-size: 13px; line-height: 15.333332061767578px;">TEST_FORM</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,theHandle</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"><span style="color: purple;"> </span> theHandle-></span><span style="font-family: 'Courier New'; font-size: 13px; line-height: 15.333332061767578px;">test_oper</span><span style="font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt;">"Test"</span><span style="font-family: 'Courier New'; font-size: 10pt;">)</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Notice that in this case we have used a handle instead of an instance name in the <b>newinstance</b> call, and then we can use this handle in place of the <b>activate</b> command. The <b>-></b> is referred to by Uniface as the "dereference" operator, and is processed with a precedence of 2 (with only field indirection being higher).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">So let's try these two different ways of activating an operation (in this case a very simple operation that simply <b>return</b>s out immediately). The <b>newinstance</b> command is done before the loop, and the <b>activate</b> (or equivalent handle call) is done inside the loop, 200,000 times...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Using <b>activate</b>: 2.56, 2.61, 2.60 (about 2.6 seconds)</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Using a handle: 2.39, 2.35, 2.39 (about 2.4 seconds)</span></li>
</ul>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">As you can see, using a handle is marginally quicker, although you'd have to be making a lot of calls before you really noticed the difference. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I thought that this would be even more useful when the handle references a component instance that is running on another server, such as when a form is mapped to run elsewhere, as the I thought the initial creation of the new instance would take longer here. So I ran the same operation 20,000 times (after mapping the form)...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Using <b>activate</b>: 13.39, 14.35, 12.99 (about 13.5 seconds)</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Using a handle: </span><span style="font-family: Arial, Helvetica, sans-serif;">13.56, 13.12, 12.91 (about 13.0 seconds)</span></li>
</ul>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Not much difference here either. Having said that, maybe on a chatty network the difference would be greater.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><i>Please note: You must <b>return</b> out of the operation that you call, if you <b>exit</b> out then this will destroy the handle and future calls to the operation will fail with a <b>$status</b> of -1. To clean up a handle you can either set it to <b>0</b> or "" (empty string). </i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Handles are abstract references to pretty much any Uniface object. They can be useful, especially if you want to call the same object multiple times, but they don't seem to have the performance benefits that I was expecting, not when it comes to component instances anyway.</span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com1tag:blogger.com,1999:blog-4660860057360911677.post-14056678273742577952014-06-07T16:44:00.000+01:002014-06-07T16:44:43.390+01:00Sendmessage versus postmessage<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, Helvetica, sans-serif;">If you wanted to send a message from one form to another, you could simply use <b>sendmessage</b>. This was deprecated in favour of using <b>activate</b>, a command which has become pretty much a catch-all for all sorts of earlier commands, including <b>run</b>, <b>perform</b>, and <b>spawn</b>. These all still work in Uniface 9.6, but as they were deprecated in Uniface 9.1, it's well worth trying to write these out of your code.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">One example of this might be if you have retrieved multiple records in one form, and also have a second form open with related records in it; when you scroll through the occurrences in the first form you might want to post the primary key details through to the second form, so that only the records related to the current occurrence in the first form are displayed.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In order to do this, the first form would need to have code in the "Occurrence Gets Focus" <OGF> trigger, something like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> sendmessage </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"SECOND_FORM"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"PKEY"</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"FIELD1.ENT=%%FIELD1.ENT%%%"</span><o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">As you can see, because <b>sendmessage</b> is now deprecated, it is not highlighted as a reserved word. You also get a compile warning like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> warning: 1000 - Deprecated statement 'sendmessage' used</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">You then need to have some code to receive this message in your second form, which needs to be in the "Asynchronous Interrupt" <ASYS> trigger, something like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;">the_result = </span><span style="color: red; font-family: 'Courier New'; font-size: 10pt;">$result </span><span style="color: green; font-family: 'Courier New'; font-size: 10pt;">;will be
"message"</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> message_id = </span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">$msgid </span><span style="color: green; font-family: "Courier New"; font-size: 10.0pt;">;will be
"PKEY"</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> message_data = </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">$msgdata </span><span style="color: green; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">;will
be "FIELD1.ENT=xxx"</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">When using <b>sendmessage</b> or <b>postmessage</b>, <b>$result</b> will always be set to "message". The second value that you define will become the <b>$msgid</b> and then third value will become the <b>$msgdata</b>. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><i><u>Please note</u>: If the <ASYS> trigger in the called component is blank then the application <ASYS> trigger will be called, as defined in the start-up shell.</i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">So what's the difference between <b>sendmessage</b> and <b>postmessage</b>? Can you simply go through and replace every <b>sendmessage</b> with a <b>postmessage</b>, or should you be using <b>activate</b> instead?</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Well the difference is that <b>sendmessage</b> is <i>synchronous</i> and <b>postmessage</b> is <i>asynchronous</i>, which means that potentially there's a delay before the message will be received and processed with a <b>postmessage</b>. Using an <b>activate</b> would be <i>synchronous</i> but you'd need to rewrite your code, probably moving the code in the <ASYS> trigger into an operation and then calling that from the <OGF> trigger.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Is this potential delay likely to cause a problem though? Well for starters, can we see it in practice? The answer to this is "yes", by putting sending code like this somewhere in a form (I went with the <EXEC> trigger)...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;"> putmess </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Before sendmessage"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="font-family: 'Courier New'; font-size: 10pt;">sendmessage </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TEST_PERF"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"MESSAGE"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"SENDMESSAGE"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">putmess </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"After sendmessage"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">putmess </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"Before postmessage"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">
</span><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt;">postmessage </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"TEST_PERF"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"MESSAGE"</span><span style="font-family: 'Courier New'; font-size: 10pt;">,</span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt;">"POSTMESSAGE"</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: purple; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">putmess
</span><span style="color: purple; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">"After postmessage"</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">And then putting the receiving code in the <ASYS> trigger, like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="MsoNormal">
<span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;"> putmess </span><span style="color: purple; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%;">"In ASYS:
ID=%%$msgid%%%, DATA=%%$msgdata%%%"</span><o:p></o:p></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">We can then run the form and view the message buffer...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> Before sendmessage</span><br />
<span style="font-family: Courier New, Courier, monospace;"> In ASYS: ID=MESSAGE, DATA=SENDMESSAGE</span><br />
<span style="font-family: Courier New, Courier, monospace;"> After sendmessage</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Before postmessage</span><br />
<span style="font-family: Courier New, Courier, monospace;"> After postmessage</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> In ASYS: ID=MESSAGE, DATA=POSTMESSAGE</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">As you can see, the <b>sendmessage</b> happens between the "before" and "after" (<i>synchronously</i>), whereas the <b>postmessage</b> happens at the very end </span><span style="font-family: Arial, Helvetica, sans-serif;">(</span><i style="font-family: Arial, Helvetica, sans-serif;">asynchronously</i><span style="font-family: Arial, Helvetica, sans-serif;">)</span><span style="font-family: Arial, Helvetica, sans-serif;">. This means that you have to be very careful about changing any </span><b style="font-family: Arial, Helvetica, sans-serif;">sendmessage</b><span style="font-family: Arial, Helvetica, sans-serif;"> statements into </span><b style="font-family: Arial, Helvetica, sans-serif;">postmessage</b><span style="font-family: Arial, Helvetica, sans-serif;"> statements - the code order will change, and you need to be aware of this and check this will not cause a problem.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />As far as my testing has gone, the messages are always received and processed in the order that they were posted, as you may expect from a message queue. Having said that, I've not found anything in the manuals that states explicitly that this order is enforced, so writing code that relies on the messages being processed in a particular order might not be wise.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: The deprecated <b>sendmessage</b> command was <i>sychronous</i> whereas the <b>postmessage</b> command is <i>asychronous</i>, so you must be careful if you replace one with the other. However, this is likely to be more straight forward than replacing with the <b>activate</b> command, as the manual suggests.</span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com1tag:blogger.com,1999:blog-4660860057360911677.post-33468520722522194862014-06-06T07:48:00.001+01:002014-06-06T07:49:42.754+01:00The new Uniface<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: Arial, Helvetica, sans-serif;">I read an interesting article today, so I thought I'd post a link...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<h2 style="background-color: white; color: #5f5f5f; font-family: verdana, arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 10px; margin-top: 5px;">
The new Uniface</h2>
<div class="content_details_block" style="background: rgb(255, 255, 230); border-bottom-color: rgb(110, 110, 110); border-bottom-style: dashed; border-bottom-width: 1px; border-top-color: rgb(110, 110, 110); border-top-style: dashed; border-top-width: 1px; font-family: verdana, arial, sans-serif; font-size: 16px; margin: 0px 0px 10px;">
<table border="0" cellpadding="2" cellspacing="0" style="padding: 6px 0px; width: 96%px;" summary="text"><tbody>
<tr><td style="border: none !important; font-size: 12px;" width="44"><a href="http://www.it-director.com/about/author/13860/david-norfolk.php" style="color: #000066; text-decoration: none;" title="View profile for David Norfolk"><img alt="David Norfolk" src="http://www.it-director.com/images/people/small/david-norfolk.gif" height="50" style="border: 0px;" width="40" /></a></td><td style="border: none !important; font-size: 12px;" valign="top"><strong>By:</strong> David Norfolk, <em>Practice Leader - Development</em>, Bloor Research<br />
<strong>Published:</strong> 30th May 2014<br />
Copyright Bloor Research © 2014</td><td align="right" style="border: none !important; font-size: 12px;" width="92"><a href="http://www.it-director.com/about/company/1/bloor-research.php" style="color: #000066; text-decoration: none;" title="View company profile"><img alt="Logo for Bloor Research" src="http://www.it-director.com/images/company/button/bloor-research.gif" height="33" style="border: 0px;" width="88" /></a></td></tr>
</tbody></table>
</div>
<span style="font-family: Arial, Helvetica, sans-serif;">Link to article: <a href="http://www.it-director.com/blogs/The_Norfolk_Punt/2014/5/the-new-uniface.html">http://www.it-director.com/blogs/The_Norfolk_Punt/2014/5/the-new-uniface.html</a></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Also mentioned in this article is the new Uniface branding, which if you follow <a href="https://twitter.com/AdrianGosbell/status/466144870403670016">Adrian Gosbell's twitter account</a> you will see looks like this...</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaUCJz_4gAEkKJLwWNdDt3ZSa12EnlyZi3qhMY5rSIiszz-dTJdUX2KhgF_-CuPSR-w038H1nfWy-c97N9KLxHUpwvMmpd85_9MvA0SjBt7sg5yJkZT89jFhR1nonwUZdhbrABPdTDVAE/s1600/BngUSiqIUAAigjR.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaUCJz_4gAEkKJLwWNdDt3ZSa12EnlyZi3qhMY5rSIiszz-dTJdUX2KhgF_-CuPSR-w038H1nfWy-c97N9KLxHUpwvMmpd85_9MvA0SjBt7sg5yJkZT89jFhR1nonwUZdhbrABPdTDVAE/s1600/BngUSiqIUAAigjR.jpg" height="320" width="240" /></a></div>
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Summary: Life after Compuware is looking good so far for Uniface.</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
Anonymoushttp://www.blogger.com/profile/17674229352640671257noreply@blogger.com1