ActiveVFP Basics

Topics: Developer Forum, Project Management Forum, User Forum
Nov 25, 2011 at 4:34 AM
Edited Nov 25, 2011 at 4:48 AM

I don't see any questions being answered but I will try anyway.

I created a web page with what I want, loosely based off your MultiTable sample.  3 cursors, simple stuff.  Here is what I need:

1) User picks from list on Left

2) calculations are done internally in some processing file where two cursors are created with the answers I need

3) two cursors on right are requeried.

I read the DOC file but I am still unsure of anything.  A video tutorial would really help us to use your excellent work.

My question is what are the EXACT list of basic files to load onto my web site to make this work ( I don't mean all my files - just what dlls etc )

Secondly, where do I put all my code logic, in main.prg?

Third, do I just point the user to myfile.avfp file on my site when it is finished?

Fourth, how can I test it locally?

Please answer some of our questions.  Many go unanswered from what I can tell.

Nov 25, 2011 at 5:56 AM
Edited Nov 25, 2011 at 6:17 AM

1.) Exact list of files:

Everything that's in the ZIP file along with your new .avfp files and your database.  The idea is that you just copy the contents of the ZIP file (with your modified .avfp files and database) to wherever and your app just runs.

2.) Code logic location:

You have several choices:

.avfp files (code goes between the <% %>)

main.prg (a centralized source and pre and post processing for all web requests.  For example, set your data access here in the AVFPinit routine)

another prg (where you could centralize source or include classes)

3.) do I just point the user to myfile.avfp file on my site when it is finished?

Yes.  However using default.avfp is the standard convention and will give you the option of specifying NO page on the URL (because it defaults to the default.avfp in the included config)

4.) how can I test it locally?

If you can install IIS on your PC you can run it locally and test.  See Installing on your own IIS Server

General advice for your application: find similar code in the demo in the .avfp files.  Start by taking the 'View Code' option and looking for the <% %> tags.  Then bring the .avfp files up in an HTML editor like MS Expression and work from there.  Any VFP code that you have described should run with NO problem.  Calculations and queries can use the EXACT same VFP code you used in your desktop app.  The only thing different is the interface. No GUI - replace with HTML.

Another basic thing to understand for those not familiar with web programming:  web programs are stateless.  One web request will not automatically remember what the last request was.  Use the SESSION object to keep track of state and fix this issue.

I suspect the real learning curve for most coming from the desktop VFP world is for Web Programming in general, not really AVFP..  Any good web tutorial or book on ASP will probably help a lot.  We are using the EXACT SAME objects that Classic ASP uses:  REQUEST, RESPONSE, SESSION.  So any examples for using these objects in Classic ASP should be transferable to AVFP.

Nov 27, 2011 at 9:56 PM

OK, got it working.  Not perfect but working.  Still have a few questions but will contact you.


Nov 28, 2011 at 2:02 PM
The following has a drop down box for states: 
You can look at the code for that page which reveals: 
 states dropdown list 
	SELE * FROM states ORDER BY statename INTO CURSOR tCursor 
Which lets you populate that drop down with table data. 
Now, after a user makes a selection, you can either have a 'Submit' button or 
some JavaScript (that will automatically submit it when selected from the list) 
to go to another URL that will do the calculations on the submitted data and 
return a 'Results' page.  This could be the same page or a different page.

For a lot of the HTML, I create it in MS Expression in WYSIWYG mode to make sure it looks right and is what I want.
These HTML editors make it easy to insert tables and the like and choose every conceivable option in the HTML.
, I make that work with VFP code and ActiveVFP.