Rick Strahl's Weblog
Rick Strahl's FoxPro and Web Connection Weblog
White Papers | Products | Message Board | News |

Last 50 comments


Re: Troubleshooting Asynchronous Callbacks into FoxPro Code



Rick Strahl
1 month ago

Thanks @Christof for the additional info!

Re: Troubleshooting Asynchronous Callbacks into FoxPro Code



Christof Wollenhaupt
2 months ago

There's one more async operation that is native to FoxPro and great source of frustration. Dynamic properties in grids. VFP executes these expressions which can call methods or user-defined functions seemingly randomly. Mouse pointer movement and the window placement of other applications impact when a dynamic expression are triggered.

In one application we have one nasty problem that appears to be related to dynamic expressions, although we are not entirely sure yet. VFP switches the data session of one complex form to the default data session at random lines in a form methods for some customers. We have added debug code to every single SET DATASESSION command and know that none of them are executing. Same for any timer event. So frustrating.

DOEVENTS works well in EXEs. Unfortunately, it's one of those commands that are not supported in an MTDLL, because VFP doesn't own the UI thread there. This leads to all kind of strange behavior with callbacks and kernel wait states when the VFP9T runtime is used. In AFP I've mitigated this issue by implementing my own event loop using GetMessage, TranslateMessage, DispatchMessage.

VFP interrupting after a line can occur in unexpected circumstances:

  • SQL statements that have user defined functions
  • While reports are generated
  • Right at the beginning of an error handler

When VFP executes other code outside a wait state (READ EVENTS, MessageBox, etc.) it's in my experience more likely to do so upon entering or returning from a subprocedure. It appears that the code that manages DO levels also performs some checks.

The code interrupting the SCAN loop can be hard to debug because it also depends on the optimization state of SCAN expressions and filters. VFP will not reevaluate optimized expressions in SCAN loops, but it does so with non-optimizable expressions. If one of the side effects of the code that was called asynchronously impacts the filter condition, you suddenly see errors when adding or dropping an index, even when the code in neither the handler nor the SCAN loop has changed at all.

Re: Visual FoxPro and Multi-Threading



Sued Jorge Nassar
3 months ago

Hello Rick.

We have a problem to solve and I ask you if has some routine or API that do something like threads.

The atual cenario:

we must use three timers to execute differents routines in different times. Example:

Timer1 -> routine A -> at each 30 seconds

Timer2 -> routine B -> At each 60 seconds

Timer3 -> routine C -> at each 10 seconds

This cenario cause many problems because one timer in execution stops the others, creating a fila. So, the 10 seconds timer stops the others that never executes.

My question: any routine or API to generate independ threads or something to simulate my cenario?

Thanks a Lot

Re: UTC Time in FoxPro



Rick Strahl
4 months ago

@Matthias - GetUtcTime() uses GetTimeZone() to get the time offset?

Re: UTC Time in FoxPro



Matthias
8 months ago

Sorry, but this functions are NOT working correctly! Especially the GetUtcTime() is incorrect. Your function GetTimeZone() checks for daylight-savings-time, but GetUtcTime() does not! When passing a datetime as parameter to the GetUtcTime() function, you have to check, if the given datetime is in daylight-savings-time or standard-time. If you run that function in winter, it gives a different result compared to if you run it in summer!

Re: Drive Mapping in Web Applications



Emin Kazok
11 months ago

Mapping as part of startup in group policy did the trick. Thank you very much.

Re: Calling JSON REST Services with FoxPro and wwJsonServiceClient



Rick
May 13, 2019

@Phil - you can use wwDotnetBridge to call that .NET Component to encode your message.

Re: Calling JSON REST Services with FoxPro and wwJsonServiceClient



Will
May 13, 2019

Rick,

Great app and nice (though somewhat cryptic) descriptions of what can be done with it.

PLEASE, PLEASE address the OAUTH 2 signature question posed by Phil on Feb 26. I am trying to accomplish the exact same thing, and I'm an absolute noob when it comes to API/JSON services.

Many thanks, Will

re: Fixing wwDotnetBridge "Unable to load Clr Instance" Errors



Chris B
October 24, 2018

Rick-

We are getting a similar "Clr Instance..." error but with a different hash identifier as follows:

Unable to load wwDotNetBridge: Unable to load Clr instance.0x8007000e:

We are using the WW library v.6.15 DtNetBridge DLL with a custom VFP v.09x enterprise platform on our LAN. VFP and the enterprise platform is running on Windows 2012 R12 Server and have .met v4.7 running as well.

The error is odd as it is occasional/intermittent and does not always occur. It just started occurring today.

Any ideas?

Chris

re: Web Connection and TLS 1.2 Support



Rick Strahl
September 14, 2018

@Darko - if you're going to use an EXE maybe you should just shell out and use curl instead. It has a lot of capabilities and it too can work just fine without the Windows TLS stack and it's a well known interface that works for all sorts of things beyond just HTTP.

re: Using CreateProcess API instead of the FoxPro ! RUN command



Robert
August 09, 2018

Rick,

Sorry I forgot to mention that I'm running a VFP compiled exe with createprocess()

Rob

re: Using CreateProcess API instead of the FoxPro ! RUN command



Robert
August 09, 2018

Rick,

I can get start a process using createprocess() but the lhProcess number is different to the PID listed in the TaskManager.

So when I use OpenProcess(PROCESS_QUERY_INFORMATION+PROCESS_VM_READ,0,lhProcess) it fails to open the handle.

Is there a way to get the correct pid back or is enumerating all the processes the only way to go?

Rob

re: Web Connection and TLS 1.2 Support



Darko Kezic
July 05, 2018

Hi, thanks for sharing this.

I used in my various VFP applications directly Windows AJAX with l_oHttp = CREATEOBJECT("MSXML2.ServerXMLHTTP") ... and was biten with TLS 1.2 issue on various client PCs.

At the end, I created small EXE with Golang which only connects to server and returns result. Then I called this EXE instead of MSXML2.ServerXMLHTTP with l_oShell = CREATEOBJECT("Wscript.Shell") ...

Yes, it looks silly to call another EXE for every HTTP request, but this was only secure way to do it on older Windows.

re: Visual FoxPro and Multi-Threading



David Phillips
May 29, 2018

Thank you Rick you a legend. FoxPro is so good with handling data it will be hard to find an alternative in the future unless someone reinvents it in a multithreaded form. Hopefully we can keep it going for another 20yrs or so. There is still Cobol Code out there that is 58yrs old and still running.

re: Web Connection and TLS 1.2 Support



Jon
May 17, 2018

Thanks, Rick--great information, as always!

re: Web Connection and TLS 1.2 Support



Michael Birnholz
April 11, 2018

Rick - discovered a few minutes ago that another issue when trying to resolve this is the default settings for IE Enhanced Security Settings Configuration. If these are both active you will not be able to open this url https://api.authorize.net/xml/v1/request.api if you are running Windows 2012 R2. If you deactivate for both administrators and users the page will open.

re: Writing to the Windows Console from Visual FoxPro



Randy H
April 04, 2018

I know we all hate flashing command windows, but:

STRTOFILE("systeminfo >systeminfo.txt","runsysteminfo.bat") RUN /n runsysteminfo.bat sysitext= FILETOSTR("systeminfo.txt")

I do like simple solutions.

re: Calling JSON REST Services with FoxPro and wwJsonServiceClient



Phil
February 26, 2018

Hi Rick,

I'm trying to figure out how to use wwJsonServiceClient to generate an OAUTH 2.0 signature.

Their API docs have an example: The signature is sent in a header named BDXAPI_NAME.

MessageDigestPasswordEncoder encoder = new MessageDigestPasswordEncoder("SHA-1"); StringBuilder sb = new StringBuilder(); sb.append("bdxapikey").append("=").append(bdxApiKey).append("&"); sb.append("bdxapiClientId").append("=").append(clientId).append("&"); sb.append("bdxapisecret").append("=").append(bdxApiSecret); model.setSignature(encoder.encodePassword(sb.toString(), null)); return model;

re: FoxPro EXE DCOM Configuration on 64 Bit Systems



Mandie
February 16, 2018

Stejpan,

Did you ever find a resolve for this? We are migrating our website over to a new Windows 2012 Server and are not able to get the foxpro dlls to work even when we have registered them successfully?

Thanks.

re: Calling JSON REST Services with FoxPro and wwJsonServiceClient



Rick Strahl
February 09, 2018

Yes you can call CreatewwHttp() which returns a wwHttp instance once which you can set any wwHttp settings. That instance is then used in the request:

oProxy = CREATEOBJECT("wwJsonServiceClient")

*** Create custom Http Object for Authentication
loHttp = CREATEOBJECT("wwHttp")
loHttp.cUsername = "ricks"
loHttp.cPassword = "seekrit22"
loHttp.AddHeader("user_token","3241231")

*** Pass it to the proxy to use
loProxy.CreatewwHttp(loHttp)

loArtist = loProxy.CallService("http://albumviewerswf.west-wind.com/api/artist",loArtist,"PUT")

IF  loProxy.lError
   ? loProxy.cErrorMsg
   RETURN
ENDIF

? loArtist.Albums.Count

re: Calling JSON REST Services with FoxPro and wwJsonServiceClient



Christian
February 09, 2018

I like the idea using the wwJsonServiceClient, however is this also possible with headers? Using HTTP call I would normally so something like that: loHTTP = CREATEOBJECT("wwHTTP") loHTTP.AppendHeader("user_session", lcUserSession) lcHTML = loHTTP.HTTPGet("http://192.168.168.155:7564/api/v1/projekte")

re: Doing HTTP Headers right in Web Connection 5.0



Rick Strahl
August 13, 2017

Easy:

Response.Redirect("~/default.wcs",.T.)

The .T. parameter makes a permanent redirect.

re: Doing HTTP Headers right in Web Connection 5.0



Michael Hogan
August 13, 2017

Very helpful - but how would I return a 301 redirect? In my 5.x app, I do this: Response.Clear() Response.Status = "404 File not found" Response.Write("Page was not found")

TIA

re: UTC Time in FoxPro



Michael B
July 23, 2017

I am working on a delivery routing module for my application and I decided to use javascript to pass the users browser time to vfp. I then convert the hex value to a fox datetime() easily. Javascript returns the time in hex starting from 1/1/1970 (aka "epoch time).

lnUnixEpochTime = 1500847437204 ? lnUnixEpochTime/(6060606060*60) + DATETIME()

This returns: 07/23/2017 05:16:29 PM

re: Persisting Static Objects in Web Connection Applications



Thierry Nivelet
June 08, 2017

Using addproperty() in .Init() works around the COM signature issue.

Also, using state persistence the way you describe applied more to single server applications (logical servers such as COM objects)

re: IIS 7 Default Request Filtering and Web Connection



faa
May 31, 2017

Hello, i am facing the issue while using request filtering option. My website didn't work until I add '.' in allowed list. I am unable to find which particular extension I am missing. Thanks in advance.

re: Handling Multiple Screens in Visual FoxPro Desktop Applications



P.C.
April 27, 2017

Yes, the _screen.top and _screen.left can obtain value -32000 which is hard to find on any monitor...

This can happen when the main FoxPro window is minimized.

Foxpro application



Techmatic systems
March 06, 2017

Thank you for your given information. Foxpro application.

Visual FoxPro is great for building desktop applications.It is a object-oriented programming to reuse components across applications.Visual FoxPro originated as a member of the class of languages commonly referred to as "xBase" languages,Visual FoxPro is a great tool for building database solutions of all sizes.

re: Clicks not working in Internet Explorer Automation from FoxPro



Sam
February 03, 2017

Hi Thank you, thank you are a genius, i was about to setup a machine with older OS and IE. oButton.Click(.F.) is a life saver.

re: Calling JSON REST Services with FoxPro and wwJsonServiceClient



Jon
December 13, 2016

Thank you Rick--great stuff as always. And a cool plug for a great band in your example (Accept)!

re: Fixing wwDotnetBridge "Unable to load Clr Instance" Errors



Ian C.
December 01, 2016

Hi All.

There now exists a command-line tool to unblock these downloaded files. PowerShell has the Unblock-File commandlet.

See http://ss64.com/ps/unblock-file.html

re: Visual Studio Gets Support for FoxPro Files



Richard Kaye
November 29, 2016

The link for the syntax highlighting extension has some extraneous text at the beginning of the URL, Rick.

re: Visual Studio Gets Support for FoxPro Files



Rick Strahl
November 24, 2016

Cetin - this is actually not an official Microsoft language add-in. Mads just built this on his own and FoxPro merely uses the TextMate add in to provide FoxPro support. The individual languages are not supported by this add-in but rather they are re-using existing Textmate add-ins from other tools (in this case Matt Slay's Sublime implementation). That implementation only provides highlighting not auto-complete features.

TextMate syntax supports better autocomplete, but the language file has to be built up to support this. The source code for the plug-in is available so you can contribute to make it better yourself instead of crying about it. Guaranteed nobody at Microsoft is going to do it for us...

re: Visual Studio Gets Support for FoxPro Files



Cetin Basoz
November 24, 2016

I downloaded and installed the extension in an excitement (besides VFP, I have been using C# and Go and seeing Go there made me more happy initially). However it is a total disappointment. It doesn't even work as well as VFP's own editor.

Come on Microsoft you could do it better for your own product! Notepad++ is doing that highlighting for years (not surprising after the failure they made announcement "VS on Mac" has turned to be another big disappointment with their ridicilous license aggrement).

re: Detecting hung Objects in Visual FoxPro



Matt Slay
September 25, 2016

Good grief... Every time I run into a VFP problem, I dig into it enough to think I understand the issues, and when I Google during my research, Rick has already tackled it and explained it well enough to help me finish solving my problem. Again!

I have now added Dispose() method into my base business object class, and my objects can now be cleanly and fully released from memory.

Thanks, Rick!!

re: Detecting hung Objects in Visual FoxPro



Eddie Caldwell
September 09, 2016

Thanks Rick for yet another informative post. On a similar note, I was looking for a hung object but the memory leak turned out to be a foxpro feature. When foxpro loads an image like with the image control, it keeps the image in memory in case it is needed again. You have to issue [release resources] or [release resource <>] to free up the memory.

re: Slow SET PROCEDURE TO and NEWOBJECT()



Matt Slay
June 28, 2016

Wow... almost 10 years later and today I was researching slow client app form load times on forms that use 30-40 Business Objects to present data field and grids to the user.

40 BOs were taking 7-8 seconds to new up when the form launched while running in an EXE, but only 1-2 seconds when running the same code from within the VFP IDE.

I blogged about my discovery, research, and remedy. Link below. In the post I also give props to Rick for blogging about this a decade ago.

http://mattslay.com/foxpro-newobject-fast-here-slow-there/

re: Calling JSON REST Services with FoxPro and wwJsonServiceClient



Rick Strahl
May 28, 2016
  1. Yes you can return cursor data by using "cursor:TQuery" as a string to specify the cursor in a property. The cursor is turned into an array and sent as JSON. Can be the top level result or set on a property assuming the cursor is open. Cursor serialization is one way - you can't directly deserialize an array into a cursor. You can however use CollectionToCursor() to dump the result object back into a cursor/table as long as the table exists.

  2. Memo fields are just text and it just works. Nothing special about memo fields. Binary data is converted base64 and sent.

re: Calling JSON REST Services with FoxPro and wwJsonServiceClient



Naeem
May 27, 2016

Hi Rick,

Nice addition in west wind client tools. I have following questions.

  1. In VFp, table structure can be passed with cursortoXml. Is it possible with Json services?

  2. How memo field data is passed with Json services ?

TIA Naeem

re: Transparent Bitmaps on Buttons and other Controls



Paul Weisberg
April 03, 2016

Great article! I found this while searching for a similar problem. One thing I just discovered for myself, is that when you assign a PNG file to the picture property of a control, FoxPro locks the resource file such that it cannot be used in another control and other file methods like fopen() on that picture file will fail. This is not true for BMP files, nor is it true for PNG files that have no transparency. This is obviously some quirk in the way that FoxPro handles transparent PNG files. I expect that the above solutions will work nicely!

re: How to work around Visual FoxPro's 16 Megabyte String Limit



FoxInCloud
March 14, 2016

Hi Rick,

Attempted to modify wc6/classes/wwAPI > EncodeDBF() to support files larger than 16Meg, couldn't work it out, any idea why?

FUNCTION EncodeDBF LPARAMETERS lcDBF, llHasMemo, lcEncodedName

LOCAL lcResult, lcFPT

lcDBF = Iif(Vartype(m.lcDBF)="C", Upper(ForceExt(m.lcDBF, 'dbf')), "") if !File(m.lcDBF) return '' endif

lcFPT = ForceExt(m.lcDBF, 'fpt') llHasMemo = m.llHasMemo and File(m.lcFPT) lcEncodedName = Evl(m.lcEncodedName, JustFname(m.lcDBF))

lcResult = ''; + "wwDBF"; && 5 + Padr(m.lcEncodedName, 40); + Str(Len(FileToStr(m.lcDBF)), 10); + Iif(m.llHasMemo; , Padr(ForceExt(m.lcEncodedName, "fpt"), 40); + Str(FileToStr(m.lcFPT), 10); , Space(50); ); + ''

lcResult = m.lcResult + FileToStr(m.lcDBF) && 2016-03-14 thn -- {en} attempt to work around the 16 MB VFP limitation - https://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=882 && 2016-03-15 thn -- {en} _cliptext = m.lcResult && 2016-03-15 thn -- {en} wwDBFAWADAPTERDETAIL.DBF 19106822 && 18,22 MB && 2016-03-15 thn -- {en} String is too long to fit (Error 1903)

lcResult = m.lcResult + Iif(m.llHasMemo; , FileToStr(m.lcFPT); , ''; )

return m.lcResult ENDFUNC

re: How to work around Visual FoxPro's 16 Megabyte String Limit



FoxInCloud
March 14, 2016

Hi Rick,

Can't find 'oPostStream' and 'cPostStreamClass' in WC6's wwHTTP. Did you implement these properties somewhere else?

Thanks

re: Custom Manifest Files in Visual FoxPro EXEs



Rick Strahl
March 06, 2016

@Tomas - Exe execution doesn't work with registrationless COM due to the extra DCOM related entries. It only works for DLL servers including OCX files (which are just renamed DLLs).

re: Custom Manifest Files in Visual FoxPro EXEs



Tomas
February 27, 2016

Registrationless COM Activation requires that during using vfp exe, dll must be near vfp exe, does not it?

re: UTC Time in FoxPro



Jon
January 13, 2016

Almost any time I have a VFP question or problem, I need look no further than your blog--very helpful, as always. Thanks for continuing to be such a great resource for VFP developers.

re: String Tokenizing based on StrExtract()



Rick Strahl
November 29, 2015

It's been real handy to have this function. In Help Builder I dozens of places where this stuff comes in handy. My MarkdownParser class in Web Connection too uses this in a couple of places. It's reduced a few very common use cases to two lines of code.

re: UTC Time in FoxPro



Vince Stevens
November 25, 2015

Hi Rick, The code examples are great.. many thanks... but do you know a way of determining the UTC of a particular country on a particular date... I am attempting to write code to calculate the the flight time from one location to another, on a given date, and passing back the correct local time of arrival... Any help would be much appreciated. Vince

re: String Tokenizing based on StrExtract()



Doug Hennig
November 20, 2015

I have to do this stuff frequently as well, and interestingly, like in your case, it usually involves parsing a comma-delimited list (usually column names, such as in a SQL SELECT statement) where one of the items in the list could contain commas, such as SELECT [This is a dumb column name, right], SomeOtherField ... I pretty much use the same technique (placeholders) but hadn't thought of creating a helper class.

re: Handling Multiple Screens in Visual FoxPro Desktop Applications



BC
November 10, 2015

My Foxpro disappeared as you had explained but I don't even have a second monitor. Somehow, when I double clicked, it ran with just the icon at the bottom. No matter how I clicked on it, the screen didn't appear then I saw this post. I used Notepad to create a prg file with the following codes and then dragged this prg file to the VFP icon to run. My screen popped back. Wonderful.

_Screen.left=5 _Screen.top=5

© Rick Strahl, West Wind Technologies, 2003 - 2020