Saturday, February 1, 2014

LOCATE vs SEEK, which is faster?

From time to time someone would inquire which is faster?  LOCATE or SEEK? And the answer mostly is it depends, if the records are small, then the speed difference is negligible enough.  True.  But that does not still answer which really is faster.  When we say faster, it has to be at least a nanosecond quicker than the other one.  We are not arguing "how" fast but "which" is faster.



To understand better which is really faster, we have to first understand how the two differs.  How does LOCATE performs searching?  How does SEEK performs searching?  Let us start with SEEK() first.

HOW DOES SEEK() PERFORM SEARCHING?

Thursday, January 30, 2014

Slow Connection? Sniff your way out!

This is actually mostly for IT personnel but is very useful as well for developers encountering slow connection on LAN.  Speaking as both, one thing that we face most of the time is degradation of speed on the network and the problem is it can be anything such as wrong design in our app, faulty hardware like switches and lan cards, or a malware flooding the network causing heavy traffic.

As an IT Manager, what I do on my end, for lack of proper tools before, is to trace things manually.  Sometimes with the help of IpSnooper tool I shared in foxite, weblogs and blogspot, I was able to pinpoint which machine a specific IP Address belongs to.  But that is if you will be able to trace which IP is flooding the network.

For some cases, like I said, I have to do it manually (with my IT guys' assistance) by observing the speed  of the network or even internet access by unplugging one by one (and reconnecting back) each connection on our switch.  And I was able to trace the units causing the flooding that way.  But...... that is the hard way.

Monday, January 6, 2014

Printer Environment on Report, when to save and when not to!

In earlier versions of VFP (before 9), Printer Environment is by default saved onto the report itself.  But then there are cases where because of that, when our app is installed on a client's machine and that machine has a different printer than what we have when we design the report and compiled the app into exe, the report output on the client machine may generate a much different output than what we are expecting like difference on dimensions, margins, font sizes, spaces, some portion cut-off, etc.  And the solution to those problems is to hack into the FRX and clear out these printer environment from within so it will be free of the settings of a "specific" printer.

For these reasons, in VFP9, VFP team saw the need to reverse the process by not saving printer environment anymore within the report.  They made it optional by adding a checkbox in Page Setup of a report that allows us to save or not printer environment.  And by reverse, I mean the default now is it is no longer saved.

Question is, if saving printer environment results to unwanted outputs that has often led developers in lower versions of VFP to always hack the frx files, why should we tick it then?  Why is this option still given to us?  Why not simply remove this feature?  Is there still any use for this?

Wednesday, September 11, 2013

Grid Dynamics' Power!!!

What is Dynamic?

Adjective
(of a process or system) Characterized by constant change, activity, or progress.
Noun
A force that stimulates change or progress within a system or process.

So Dynamic can change.  It is the opposite of being Static or Fixed.


In VFP Grid, there is only one real row and the rest are just mirrors of the first one manipulated by VFP to show different values. It means that conditions on objects (textbox, combobox, checkbox, etc) on a column are static.  What condition and formatting you applied to an object of a cell applies to the rest of the cells belonging to that column.

But since there definitely is a need for us to reflect on a cell certain values based on several conditions, then that is where Dynamic Properties of a grid is needed (see VFP help on available Dynamic Properties).  A very powerful feature of grid that makes me prefer it over to listbox.


Yesterday inside Foxite, I finally understood the need of a fellow member with the sample he provided which is allowing a combobox inside a column to change values or sort of being filtered based on a combination of values of two fields (or column1 and Column5).  And I showed him how to attain that by employing DynamicCurrentControl Property of the grid.

What is DynamicCurrentControl?

Please just refer to my early posting in Weblogs about this: http://weblogs.foxite.com/sandstorm36/2008/08/09/placing-various-images-on-a-grid/

Tuesday, July 30, 2013

How to make an Ugly App


Being away from my wife for more than a month doing admin works again, this time in Port Moresby, I have time to play with my form's appearances during the night.  With her besides me, of course I cannot do that as that will mean war!  LOL!  And honestly, I should not do that as well because there should be a fine line between being a developer/designer and a loving husband.

Anyway, being alone here on my room at night and not still into coding mood these days, I work instead on finding out how to make my forms look better by creating what I hope are stunning but not too comical forms.  So I play with mixing colors, creating some effects for my forms' appearances, plus some new tricks on some menu/button effects for further eye candies. While this post won't and can't help anyone on coding matters, I hope this will at least give you ideas on how to make your forms uglier.... err... prettier.   Here are some pointers:

a.  Use Photoshop.  This is the best tool I have known so far where I can design stunning effects to serve as form's background.  Play with layers, Layer Styles, Filters, Opacity and Fill.

b.  Transparent Pageframes.  Well I shared this before here but if this is ignored, I cannot blame them.  The sample I gave there is very simple and does not leave much to imagination.  But take a look at the effect when used in my real forms.

Friday, July 26, 2013

Insert Words, Combine/Merge RTF Files

This came from a question inside foxite forum when a member tried to merge two RTF files into one via FILETOSTR() and STRTOFILE() and the member cannot see the second set of words added at the end of the rtf document, and wonder why.  So here is the explanation.

An RTF file starts with {\rtf1 and ends with corresponding }. So if you combine two or more rtf documents via a FILETOSTR() then later STRTOFILE(), each of those will have their own opening and closing RTF codes.  And an RTF document will just read whatever is within its opening and closing codes that whatever is added after the closing bracket will be ignored.

Here is a test for you to see better.  Copy these codes and paste to a notepad, save with an RTF extension, quit  and open the file in wordpad or msWord:

{\rtf1\Ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset0 Arial;}}
\viewkind4\uc1\pard\f0\fs20 This is sample\f1\fs18
\par }


Now, we will simulate FILETOSTR() and STRTOFILE() with additive clause at the end.  Imagine if we copy the same set of codes and paste it twice inside, on notepad, it will look like this:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset0 Arial;}}
\viewkind4\uc1\pard\f0\fs20 This is sample\f1\fs18
\par }
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset0 Arial;}}
\viewkind4\uc1\pard\f0\fs20 This is sample\f1\fs18
\par }

Save it, close and open in msWord or Wordpad.  Surprise!!! There is still one line of word "This is a sample"  instead of two.  Again because an RTF ignores anything that is after the closing } bracket.

So we cannot blame FILETOSTR() and later STRTOFILE() as those are doing properly what they are designed for.  Either you clean up the RTF codes yourself or better use Word Automation so it will clean the RTF codes for you.

Here is a sample of word automation:
Set Safety Off
Declare Integer ShellExecute In shell32.Dll ;
      INTEGER hndWin, ;
      STRING cAction, ;
      STRING cFileName, ;
      STRING cParams, ;
      STRING cDir, ;
      INTEGER nShowWin
#Define wdStory           6
#Define wdPasteDefault    0

Local lcSource, lcTarget
lcTarget = Addbs(Getenv("TMP"))+"Target.rtf"
lcSource = Getfile("rtf")
If !Empty(m.lcSource)
      Create Cursor junk (myMemo M)
      Insert Into junk Values (Filetostr(m.lcSource))

      * Let us create the RTF file
      Strtofile(junk.myMemo,m.lcTarget)

      * Now we will make two copies of the content in a single RTF file
      Local loRTF As Word.Application
      loRTF = Createobject("Word.Application")
      With loRTF
            .DisplayAlerts = .F.
            .Documents.Open(m.lcTarget)
            * Copy everything, paste as a new set, save and quit
            .Selection.WholeStory
            .Selection.Copy
            .Selection.EndKey(wdStory)
            .Selection.PasteAndFormat(wdPasteDefault)
            .ActiveDocument.SaveAs(m.lcTarget,6)
            .ActiveDocument.Close
            .Quit
      Endwith
      * Check using wordpad
      ShellExecute(0,"Open","wordpad.exe",m.lcTarget,"",1)
Else
      Messagebox('You aborted!')
Endif




I hope this helps you on your needs!

Tuesday, July 16, 2013

How Uglier can a VFP app get?

Been gone for quite a while now doing admin and other managerial jobs lately and I felt I am loosing my grip on developing but every time I think of doing it, my mind sorts of auto shuts down, LOL!  I guess that is what normally happens when you have plenty other things to think of.

Anyway, I looked for something that can entice me and lure me back into developing and GUI designing and I found it in my Assets Masterfile module which image I have posted before under Various Images on a Grid blog.  Now, I wanted to change that grid into an HTML Browser instead for smoother scrolling effects.  That is the start and then I decided to make it more looking like a website maybe?