Tuesday, September 12, 2006

I should've posted this earlier, but I’ve been running into some health issues lately that precluded me from doing it.

 

I was wrong when I said before that the RSS API (events interface) was not working with VFP; as a matter of fact,  Alan Griver indicated in my previous post that he had it working and was about to do a presentation with it, so to me that was the confirmation of my previous suspicions, i.e., that I was not using the right code.

 

Using the correct events interface invocation “made the trick” to make it work.

 

There is still an outstanding issue that I have to figure out: I get the same error described in previous posts that pops up after I try to download several feeds individually, I have a couple of things in mind that I am going to try.

 

Here’s a sample of the code that will allow you to see on the VFP screen the RSS activity and also record it to a csv file for later review in a table format (for example you could use these 2 lines of code

CREATE TABLE feedslog (Occurred t,EventMess c(150),FeedPath c(200),FeedOldpat c(200),ItemCount n(9),ErrorNo n(9))

APPEND FROM FeedEventsLog.CSV TYPE csv):

 

 

* RSS Events

CLEAR

 

#DEFINE FES_ALL 0

#DEFINE FES_SELF_ONLY 1

#DEFINE FES_SELF_AND_CHILDREN_ONLY  2

#DEFINE FEM_FOLDEREVENTS  0x00000001

#DEFINE FEM_FEEDEVENTS  0x00000002

 

PUBLIC FeedErrors

DIMENSION FeedErrors(13,2)

FeedErrors(1,1)= 0

FeedErrors(1,2)= "OK" 

FeedErrors(2,1)= 1

FeedErrors(2,2)= "DOWNLOAD FAILED" 

FeedErrors(3,1)= 2

FeedErrors(3,2)= "INVALID FEED FORMAT" 

FeedErrors(4,1)= 3

FeedErrors(4,2)= "NORMALIZATION FAILED" 

FeedErrors(5,1)= 4

FeedErrors(5,2)= "PERSISTENCE FAILED" 

FeedErrors(6,1)= 5

FeedErrors(6,2)= "DOWNLOAD BLOCKED" 

FeedErrors(7,1)= 6

FeedErrors(7,2)= "CANCELED" 

FeedErrors(8,1)= 7

FeedErrors(8,2)= "UNSUPPORTED AUTHENTICATION" 

FeedErrors(9,1)= 8

FeedErrors(9,2)= "BACKGROUND DOWNLOAD DISABLED" 

FeedErrors(10,1)= 9

FeedErrors(10,2)= "Feed Does NOT EXIST" 

FeedErrors(11,1)= 10

FeedErrors(11,2)= "UNSUPPORTED MSXML" 

FeedErrors(12,1)= 11

FeedErrors(12,2)= "UNSUPPORTED DTD" 

FeedErrors(13,1)= 12

FeedErrors(13,2)= "DOWNLOAD SIZE LIMIT EXCEEDED" 

 

oFeedMgr = NEWOBJECT("Microsoft.FeedsManager")

oRootFolder = oFeedMgr.RootFolder

oFeeds=oRootFolder.Feeds

 

 

x=NEWOBJECT("myFolderEvents")

 

IF EVENTHANDLER(oRootFolder.GetWatcher(FES_SELF_AND_CHILDREN_ONLY ,FEM_FEEDEVENTS  ),x)

     Wait window nowait  "Feeds Interface Instantiated!"

ELSE

     Wait window nowait  "Feeds Interface Instantiation FAILED!"

ENDIF

 

RETURN

 

DEFINE CLASS myFolderEvents AS session OLEPUBLIC

 

     IMPLEMENTS IFeedFolderEvents IN "c:\windows\system32\msfeeds.dll"

 

     PROCEDURE IFeedFolderEvents_Error() AS VOID;

                    HELPSTRING "Occurs when a feed folder event error occurs."

     * add user code here

                    EventsLogger("Folder Event Error","")

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FolderAdded(Path AS STRING) AS VOID;

                    HELPSTRING "Occurs when a folder or subfolder is added."

     * add user code here

                    EventsLogger("Folder "+PATH+" Added",PATH)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FolderDeleted(Path AS STRING) AS VOID;

                    HELPSTRING "Occurs when a folder or subfolder is removed."

     * add user code here

                    EventsLogger("Folder/subfolder "+PATH+"removed.",PATH)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FolderRenamed(Path AS STRING, oldPath AS STRING) AS VOID;

                    HELPSTRING "Occurs when a folder or subfolder is renamed."

     * add user code here

                    EventsLogger("Folder/subfolder "+oldPath+ " RENAMED to "+PATH,PATH,oldPath)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FolderMovedFrom(Path AS STRING, oldPath AS STRING) AS VOID;

                    HELPSTRING "Occurs when a folder or subfolder is moved from this folder."

     * add user code here

                    EventsLogger("Folder/subfolder MOVED FROM "+oldPath+" to "+PATH,PATH,oldPAth)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FolderMovedTo(Path AS STRING, oldPath AS STRING) AS VOID;

                    HELPSTRING "Occurs when a folder or subfolder is moved to this folder."

     * add user code here

                    EventsLogger("Folder/subfolder "+oldPath+" MOVED TO "+PATH,PATH,oldPAth)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FolderItemCountChanged(Path AS STRING, itemCountType AS Number) AS VOID;

                    HELPSTRING "Occurs when the aggregated item count of a feed folder changes."

     * add user code here

                    EventsLogger("Folder ITEM COUNT for Folder "+PATH+" Changed to "+ALLTRIM(STR(itemCountType)),PATH,,itemCountType)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedAdded(Path AS STRING) AS VOID;

                    HELPSTRING "Occurs when a feed is added to the folder."

     * add user code here

                    EventsLogger("Feed "+PATH+" Added",PATH)

 

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedDeleted(Path AS STRING) AS VOID;

                    HELPSTRING "Occurs when a feed is deleted from the folder."

     * add user code here

                    EventsLogger("Feed "+PATH+" Deleted",PATH)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedRenamed(Path AS STRING, oldPath AS STRING) AS VOID;

                    HELPSTRING "Occurs when a feed is renamed."

     * add user code here

                    EventsLogger("Feed "+PATH+" Renamed",PATH)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedUrlChanged(Path AS STRING) AS VOID;

                    HELPSTRING "Occurs when the URL of a feed is changed."

     * add user code here

                    EventsLogger("Feed "+PATH+" URL Changed",PATH)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedMovedFrom(Path AS STRING, oldPath AS STRING) AS VOID;

                    HELPSTRING "Occurs when a feed is moved from this folder."

     * add user code here

          EventsLogger("Feed MOVED FROM "+oldPath+" TO "+PATH, PATH, oldpath )

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedMovedTo(Path AS STRING, oldPath AS STRING) AS VOID;

                    HELPSTRING "Occurs when a feed is moved to this folder."

     * add user code here

          EventsLogger("Feed MOVED TO "+oldPath+" FROM "+PATH, PATH, oldpath )

 

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedDownloading(Path AS STRING) AS VOID;

                    HELPSTRING "Occurs when a feed starts to download."

     * add user code here

          EventsLogger("Feed Download "+PATH+" STARTS",PATH)

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedDownloadCompleted(Path AS STRING, Error AS VARIANT) AS VOID;

                    HELPSTRING "Occurs when a feed has finished or failed downloading."

     * add user code here

 

          lcErrorMessage=FeedErrors(ASCAN(FeedErrors,Error)+1)

          EventsLogger("Feed "+PATH+" Download "+IIF(error=0,"FINISHED ","FAILED "+lcErrorMessage),PATH,,,Error)

         

     ENDPROC

 

     PROCEDURE IFeedFolderEvents_FeedItemCountChanged(Path AS STRING, itemCountType AS Number) AS VOID;

                    HELPSTRING "Occurs when the item count of a feed changed."

     * add user code here

          EventsLogger("Feed "+PATH+" ITEM COUNT Changed to "+ALLTRIM(STR(itemCountType)),PATH,,itemCountType)

         

     ENDPROC

 

ENDDEFINE

 

 

**********************

PROCEDURE eventslogger

**********************

LPARAMETERS tcEventMEssage, tcPAth,tcOldPath,tnItemCountType, tErr

 

lcLogMessage=TTOC(DATETIME())+[,]+;

                tcEventMEssage+[,]+;

                tcPath+[,]+;

                IIF(VARTYPE(tcOldPath)=[L],[],tcOldPath)+[,]+;

                IIF(VARTYPE(tnItemCountType)=[L],[],ALLTRIM(STR(tnItemCountType)))+[,]+;

                IIF(VARTYPE(tErr)=[L],[],ALLTRIM(STR(tErr)))

 

?lcLogMessage

STRTOFILE(lcLogMessage+CHR(13),"FeedEventsLog.CSV",1)

RETURN .t.

 

 [UPDATED 10-02-06] I've added 2 flash videos of about 3 mins each showing this code working on XP  SP2 and Vista RC1.

 

posted on 9/12/2006 2:48:54 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [2]
 Friday, August 25, 2006

Despite what has been said before, nothing has changed, the same issues are still there.

Just to be on the safe side, I will continue to investigate whether I am using the correct code which, except for a property name that changed, it is pretty much the same as published before.

 

posted on 8/25/2006 3:22:02 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [3]
 Wednesday, July 26, 2006

Here's a follow up responding to the overwhelming demand of my previous posts <g>:

I've just received the following notice from msconn

Entered by Microsoft on 7/26/2006 at 11:24 AM

We have fixed the problem of events in Visual FoxPro in a build post Beta 3. You should be seeing this fix in a future public release.
-Walter [MSFT]

Cheers.

Juan Calcagno
Certified MS Believer

posted on 7/26/2006 6:27:10 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [3]
 Friday, July 14, 2006

I am a non-believer, let me tell ya.

Yes, I don't know when, but I became one at some point.

Not related to religion (or the lack of one) though and not a genetics issue either I think; the way I was raised, my mom and dad gave me the best education a son could have, I was given everything that's needed to be a double Nobel prizewinner in Physics and Peace just to give you an example.

Who knows, maybe the software world I am in made me the way I am these days.

If you've read my latest posts, you know I've been trying to use the RSS COM platform in IE 7 to create an RSS reader in Visual Foxpro, but haven't been succesful because, among other issues, it is not possible to bind RSS events from VFP.

Calvin Hsia found a solution, but his example is for cases that EVENTHANDLER can already address fine. He left as an exercise for the reader to figure out how to bind events for other COM platforms that don't quite work with EVENTHANDLER, indicating that following his example shouldn't be hard to figure it out.
Calvin, please believe me, IT IS.

OK, it's not that bad if you are good at C++, Assembly, x86 machine code and VFP.
But I'm not planning to learn 3 of those 4 languages at least in my next 7 lives.

Craig Boyd thanked Calvin because based on his example he found a solution to make RSS COM platform work with VFP. But Craig never posted his solution, although Calvin ceded him the honor to do so.

See? This is the kind of attitude that made me a non-believer. <g>

(read the thread at http://blogs.msdn.com/calvin_hsia/archive/2006/06/14/631604.aspx#634605)

A while back Andrew MacNeill suggested me to post the issues at the IE7 beta feedback MS web site, which I did with the same hope one buys a ticket for the big jackpot of the state lottery.

For the reasons exposed, I was in shock when I've got a response from the IE7 team that I'd like to share below.

Here's an excerpt from the email I received from the MS Connect Team,

There are 4 issues: 

1. unable to bind to RSS events: We have repro'ed it and are investigating the cause.

2. Download/update/refresh issue: We are unable to repro the hang after 4 downloads. Would it be possible to provide download logs created with http://fiddlertool.com ? It will create a snapshot of http traffic and will hopefully help us understand the issue better.

3. The feed view doesn't update when the feed is refreshed in the background. This is by design since there are cases where users would "loose" their read/unread state and the scroll position on the page if the page would automatically refresh.

4. Unable to delete feeds: This issue should be fixed in IE7 Beta 3. In previous releases an application could hold on to the Feed COM object and thereby preventing another application from deleting the feed. In Beta 3 we changed to an optimistic locking model allowing applications to delete feeds even if another app has the feed open.

Not bad for a non-believer huh?
Cheers from yours truly,

JLC.
Certified Non Believer

Ah! one more thing, Craig Boyd, if you are planning to conquer the world with VFP, in addition to need loyal soldiers, you will have to feed them as well...<g>

 

*This is the file MS feedback requested in item 2 testingie7.zip (355.88 KB)
posted on 7/14/2006 2:10:19 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [2]
 Wednesday, June 07, 2006
Experiencing the bitter taste of an unfinished software.
posted on 6/7/2006 6:37:37 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0]
 Friday, May 12, 2006

I used to think that blogs were the most idiotic thing in the world. That was not so long ago.

Nowadays I'd rather read blogs that surf web sites. Yes, I am the real idiot.

Who would've thought then, that I would be having fun building a VFP RSS Reader.
I will be posting more as I make progress, but here are a few pictures.

You may want to know from what I've done so far it took me less lines of code with Visual foxpro than with our, ahem rich cousin,  .NET.

[Update: forgot to mention that Calvin Hsia has built one also, using a different approach though]

posted on 5/12/2006 11:59:52 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [5]
 Thursday, March 16, 2006

I recently run into the problem of not getting the right order for records on a temporary table. This is how data looked when using and index created as follows:

INDEX ON UPPER(company_name)+UPPER(dept_name)+UPPER(EMPLOYEE_LASTNAME)+UPPER(EMPLOYEE_FIRSTNAME) TAG ciadeptemp

COMPANY_NAME,DEPT_NAME,LAST_NAME,FIRST_NAME
Company 1, null,j,c
Company 2, Sales,f,c
Company 1,Tech Support,g,c

What happened? Shouldn't I get all the 'Company 1' records before seeing 'Company 2'? Of course, but that is in case there were not null values in any of the fields that are part of the index key.

In my case, field "dept_name" accepted .null. values so the index key for that record evaluates to .NULL., therefore, appears at the top. This new index key solved it:

INDEX ON UPPER(company_name)+UPPER(IIF(ISNULL(dept_name),space(40),dept_name))+UPPER(EMPLOYEE_LASTNAME)+UPPER(EMPLOYEE_FIRSTNAME) TAG ciadeptemp

Never run into this before, so many years working with VFP but how much I've got to learn yet. Did anybody resolve this in a different way?

posted on 3/16/2006 1:01:10 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [2]
 Friday, February 17, 2006

A colleague using VFP7 asked recently about removing those pesky printer references in reports. Of course, you have a way to manually remove them in VFP8 and VFP9 (report menu-printer environment and also for VFP9 report properties).

In case you still maintain projects in VFP7 and/or upgrade report files into projects using versions 8 or 9, trying to remove those printer references (if any) automatically won't hurt your project after all. The best known option for this is to put some code in your project hook class 'beforebuild' method.

Most Fox people know that they can associate a ProjectHook visual class with their projects using the Project Menu options available; Since I couldn't send to my colleague the visual class as a file  (it was an internet newsgroup), I thought of a way to do this programatically so here's another way to do it, probably useful in case you had your classes defined in a prg. The downside is that the ProjectHook reference does not persist when you close the project.

This code takes care of creating the class file and adding at least one file to the project in order to build it as an APP, needles to say these are things needed for this example only, in a real life scenario those 2 would be existing files.

#include foxpro.h
clear
IF FILE("foo.prg")
    DELETE FILE FOO.PRG
ENDIF

IF FILE("MyClasses.PRG")
    DELETE FILE MyClasses.PRG
ENDIF

IF FILE("MyProject.pjx")
    DELETE FILE MyProject.*
ENDIF


LOCAL lcMyProjectHookVar
TEXT TO lcMyProjectHookVar noshow
    **************************************************
    *-- Class: myphook (c:\noninteractive\annunciacurrent\phookexample.vcx)
    *-- ParentClass: projecthook
    *-- BaseClass: projecthook
    *-- Time Stamp: 02/17/06 03:49:02 PM
    *
    DEFINE CLASS myphook AS projecthook


        Height = 22
        Width