Measures Concepts
GitHub icon

ActiveVFP

ActiveVFP - Programming language

< >

ActiveVFP is an open source programming language created in 2001.

#842on PLDB 23Years Old

ActiveVFP (also known as AVFP) is a server-side scripting framework designed for Web development to produce dynamic Web pages. Similar to PHP, but using the native Visual Foxpro (VFP) language and database (or other databases like Microsoft SQL and MySQL), ActiveVFP can also be used in Model-View-Controller (MVC) web applications as well as RESTful API. ActiveVFP is completely free and open source and does not require the purchase of Microsoft Visual FoxPro or any additional software. Read more on Wikipedia...


Example from Wikipedia:
* customers.prg -Customers Controller * * bypasses Main.prg and .AVFP script code * DEFINE CLASS customersController AS restController * PROCEDURE openData SELECT 0 USE (THIS.homeFolder + "customers.dbf") ALIAS customers ENDPROC PROCEDURE infoAction && GET www.hostname.com/app/customers/info RETURN "homeFolder: <b>" + THIS.homeFolder + "</b>" ENDPROC PROCEDURE getAction && GET www.hostname.com/app/customers/<id> LOCAL cCustId cCustId = THIS.Params[1] THIS.openData() SELECT CUSTOMERS LOCATE FOR custId = cCustId IF FOUND() LOCAL cJSON **USE mydbf &&test error *quick and dirty JSON cJSON = [{"custId":"] + RTRIM(custId) + [","custName":"] + RTRIM(custName) + [",] + ; ["custStat":"] + RTRIM(custStat) + ["}] RETURN cJSON ENDIF ENDPROC PROCEDURE listAction && GET www.hostname.com/app/customers/ LOCAL cHTML cHTML = "" *oEmp=newOBJECT('schedbizobj','c:\avfp5.61Demo\prg\utiltest2.prg') SET PROC to substr(oProp.AppStartPath,1,AT([\],oProp.AppStartPath,2))+'prg\AVFPutilities' ADDITIVE && Make sure you use ADDITIVE or bad things happen! THIS.openData() SELECT CUSTOMERS cHTML= oHTML.mergescript(FILETOSTR(substr(oProp.AppStartPath,1,AT([\],oProp.AppStartPath,2))+'viewtest.avfp')) RETURN cHTML ENDPROC PROCEDURE helloworld && custom method (&& GET www.hostname.com/app/customers/helloworld/) LOCAL cHTML cHTML = "" *USE mydbf *SET PROC to substr(oProp.AppStartPath,1,AT([\],oProp.AppStartPath,2))+'prg\AVFPutilities' ADDITIVE && Make sure you use ADDITIVE or bad things happen! cHTML= oHTML.mergescript(FILETOSTR(substr(oProp.AppStartPath,1,AT([\],oProp.AppStartPath,2))+'hello.avfp')) RETURN cHTML ENDPROC PROCEDURE getemployees && custom method (&& GET www.hostname.com/app/customers/getemployee/<id> oJSON=NEWOBJECT('json','json.prg') SET PATH TO oProp.AppStartPath+'data\AVFPdemo41\' select e.emp_id as id, e.first_Name as firstName, e.last_Name as lastName, e.title as title, [images/Emps/]+e.picture as picture,count(r.emp_id) as reportCount ; from employee e left join employee r on VAL(r.reports_to) = VAL(e.emp_id) ; INTO Cursor SearchResults; group by e.last_Name,e.emp_id, e.first_Name,e.title, e.picture ; order by e.last_Name,e.first_Name oJSON.keyforcursors="items" * send JSON data and properties back oResponse.ContentType = "application/json;charset=utf-8" oResponse.Write(oJSON.stringify('SearchResults')) oResponse.Flush lcHTMLout=[] ENDPROC ************************************************************************ ENDDEFINE

Language features

Feature Supported Token Example
Comments ✓
* A comment
Line Comments ✓ *
* A comment
Semantic Indentation X

View source

- Build the next great programming language · Search · Add Language · Features · Creators · Resources · About · Blog · Acknowledgements · Queries · Stats · Sponsor · Day 605 · feedback@pldb.io · Logout