FoxPro

Visual FoxPro (VFP), and its predecessor FoxPro, is a data-centric, object-oriented, procedural, database programming language and IDE from Microsoft last released in 2007 that still has some active use due to its low cost of deployment and fairly rapid development. In 2008, Microsoft released a set of add-ons for VFP's xBase components to allow interoperability with various Microsoft technologies. It allows data processing against its native file-based data tables or database servers such as SQL Server.

Share tech news, updates, or what's on your mind.

Sign up to Post

In my Visual Foxpro 9 program, I use Office Automation to process a third party Excel 97 file. All has been well for years. Now my client is dumping Office for Google Sheets. The third party file is still coming in that I need to process without Office. I found an interesting code to take XLSX without automation, but does not handle Excel 97 XLS. I asked my client to check with the third party to see if they can export as a XLSX, but in the meantime I am attempting to see if I can handle the Excel 97 without automation. I have attempted to use ODBC, from a similar question on foxite, but I don't seem to have the right code. I am hoping this has already been solved, I just haven't found it yet. Thanks in advance for your help.
0
Bootstrap 4: Exploring New Features
LVL 13
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

How to allow multiple VFP app users to transparently transfer files to a secured shared directory.

I have multiple users connecting to a RDS server hosted on my domain.  There is a VPN between my domain and the users domain.  Once connected to the RDS server, they run their VFP app.  From within the VFP app, they select a file using GetFile().  That works fine.  Once a file is selected I want to automatically transfer the file to a shared directory, locked down to admins only.  Users wont have any access to the share except to upload files to it from within the VFP app.  

Here's a mockup of the credentials provided to me to access the share:
Domain: TheUsersDomains
Username: filestorageuser (given admin rights)
Password: FileStorePassw0rd
Location: \\TheirServer\FileStorage

At first, I replaced TheirServer with their servers IP, but VFP doesn’t seem to like IPs in a path, so I added a record to my workstations and to the RDS servers Hosts files.  Then, on my workstation, I connected to the server in File Explorer, entering in the credentials, and now VFP will upload files to it from my workstation.  However, when I create an executable and send it to the RDS server and try to upload files to the shared directory, I am given an error about …invalid path…

I have found some suggestions of a work around like this (I don't want to create a mapped drive the users can access outside of VFP):
oNet = CreateObject('WScript.Network')    
0
Hi Experts

Could you clear if a TRY CATCH / Finally could run independently of an habilitated ON ERROR clause by using VFP?

Actually I'm using a customized ON ERROR clause that deviates the error and its details to a txt file preventing the system to present an error popup.

I need to check a specific part of the code about network fails or some other obscure problem that rarely ocurs and I'm planning to use a TRY/ CATCH only on this code - without inabilitate the previous ON ERROR.

Thanks in advance.
0
I need to open a browse window.  Then open a second browse window when the user closes the first one.
      
      Tbe user needs to be able to activate the Data Session window from each browse window.  
      
      If I use browse ... nowait, the Data Session Window can be accessed by selecting Window from the menu and choosing Data Session.
      
      If I leave off nowait and select Window from the menu, The Command Window and Data Session Windows are grayed out.
      
      If I use nowait on both browse commands, the second browse window is not displayed.

	USE IN SELECT('ckRemindEdit')  
    use ckRemindEdit.dbf in 0
    select ckRemindEdit
	brow fields descrip 
	
	use in select('ckBreedEdit')
    use ckBreedEdit.dbf in 0
	brow fields descrip nowait[code]

Open in new window

[/code]
0
The replace BREED commands on line 80 has been working for months and has suddenly stopped.

Replace Descrip-- fields starting on line 88 still work.


*!*	*-----------------------------------------
* -    cbBreedRemind_Update.prg
*!*	writes breed and label edits back to practices pull files
*!*	*-----------------------------------------

lparameter lcThisPath;
			lcProc; 
			lnWeekNum
			
LOCAL laDirs[1];
		 lnI;
		 lcPullFile;
		 lcPrgNm
		 
set date to YMD
		 
lcPrgNm = "ckBreedRemind_update.prg"
?
? lcPrgNm + " STARTED", datetime()

if empty(lcThisPath)
	lcThisPath = "c:\vetdata\_de\vetdata\"	
endif


local lcWeekPullFile, ;
	lcWeekPullFileNam ;
	lcPracDir;
	lnWeekNum;
	lcPath ;
	lcScrubFile	
		

set safety off 
set deleted on

if empty(lnWeekNum)
	lnWeekNum = 36
endif


lcWeekNum = "9" + alltrim(right(str(100 + lnWeekNum),2))


lcWeekPullFile = "wk" + lcWeekNum + "_pull.dbf"

use in select('ScrubFile')
lcScrubFile = (lcThisPath) + "ckBreedScrub.dbf"
use (lcScrubFile) alias ScrubFile in 0 excl

select ScrubFile

*-- Create a liast of practice dirs	
SELECT DISTINCT DefaultDir FROM scrubFile INTO ARRAY laDirs

SELECT scrubFile
INDEX ON PRRecno TAG PRRecno

*-- Close possibly open Pullfile
USE IN SELECT('PullFile')

*-- Process all dirs
FOR lnI = 1 TO ALEN(laDirs)

  lcPullFile = lcThisPath + ALLTRIM(laDirs[m.lnI]) + "\pull\" + (lcWeekPullFile)
  IF FILE(m.lcPullFile)
  
    SELECT 0
    *-- Open Pullfile
    USE (m.lcPullFile) ALIAS PullFile
    *-- Update rows 

Open in new window

0
created a simple check for the existence of a field in a remote table. It failed, despite the existence of the relevant field. To troubleshoot why, I created the following very simple code which should enable you to recreate the issue. Bear in mind that you must NOT be in the remote table. (the whole point was to avoid leaving the table I was in and disturbing the existing pointers)

Create a table called phones, with a field called PHPRIME
create or use any other table and make it current
Use PHONES IN 0

This is the code which demonstrates the problem:

FNAME=FIELD('PHPRIME','PHONES')  && that syntax clearly suggests we SHOULD be able to run the test more directly as in IF NOT FIELD('PHPRIME','PHONES')=='PHRIME'

*but it fails so I tried:

IF FNAME=='PHPRIME' && which it does
       IF NOT FIELD('PHPRIME','PHONES')=='PHRIME' AND FNAME=='PHPRIME'
             WAIT WINDOW 'BRAIN EXPLODES HERE'
       ELSE
             RETURN
       ENDIF
ELSE
      RETURN
ENDIF


So, what hidden VFP secret am I missing here?
0
I need to connect some Visual FoxPro Tables with MS SQL server, a real time connection it's not necessary as long we are able to pull and return data to the Visual FoxPro Tables from MS SQL. I have downloaded from Microsoft and tested VFPOLEDB and VFPODBC drivers with no success.
Do someone has a ODBC driver or a way to connect those two type of data, that works?
Thanking in advanced!!!
0
I am opening a browse window, running some processes, then calling another program that opens a 2nd browse window.

I need them both to stay open until the user closes them.

If I just open one, it stays open.  If I open 2, they both flash on the screen then are closed.

select table1
go top
browse fields field1, field2, field 3 nowait

Call Program2
*-Program 2
select table2
go top
browse fields field1, field2, field 3 nowait
0
I am getting Alias filemaster not found on line 31.  I have tried various things as far as workspaces with no luck.

lcThisPath = "c:\inv\act\"      
close datab all
set safety off      
***For file1 lookup *****************************************************
use (lcThisPath) + "\filelist.dbf" in 0 shared
use (lcThisPath) + "\filemaster2.dbf" in 0 exclu
use (lcThisPath) + "\filemaster2.dbf" in 0 AGAIN ALIAS filemaster2_a SHARED

      brow last for len(alltrim(file1))>3 nowait

      select filemaster2
      set order to tag ufiled

            brow last nowait

            
      USE (lcThisPath) +  "templates\" + "ckfileEdit.dbf"
      select ckfileEdit

      COPY STRUCTURE TO (lcThisPath) + "\ckfileEdit.dbf"
      *-- close template file
      use in ckfileEdit

    use (lcThisPath) + "\ckfileEdit.dbf"

**ALIAS FILEMASTER2 IS NOT FOUND HERE:

    select filemaster2
      set order to tag ufile3

    select ckfileEdit
    set relation to upper(substr(file,1,3)) into filemaster2 additive
      set relation to upper(substr(file,1,3)) into filelist_a additive
                        
            select speciesd, species, filed, file, count(*) as cnt from (lcThisPath) + "ckfileScrub.dbf" group by species, speciesd, file, filed order by species, speciesd, file, filed into table ztemp.dbf      

      Select ckfileEdit
      
      Append from ztemp
                                          
      index on upper(filed) tag ufiled
      index on upper(substr(filed,1,3)) tag ufile3
      index on upper(substr(file,1,3)) tag ubr3
      set order to
      
      browse last fields cnt:R, species:20:R, speciesd:20:R, …
0
Hi Experts!

Could you point how to correctly call a VFP generical program from command line?

Accordingly with this project:
img005

task.prg
Local lcLogfile
lcLogfile = "d:\temp\task.log"
If ADir(paFiles, lcLogfile)=0
   StrToFile("",lcLogfile,0)
EndIf 
StrToFile(Textmerge("<<Sys(16,0)>> 001 -- 002  ran at <<Datetime()>> as <<Id()>>")+Chr(13)+Chr(10),lcLogfile,1)

Open in new window


That remains at
img_EE_07_24082019.png
Called as:
img_EE_06_24082019.png
Could you check how to do it correctly?

Thanks in advance!
0
CompTIA Cloud+
LVL 13
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Hi Experts

Could you point a way to show the combobox selected options when it's disabled when using Visual FoxPro?

When enabled: - The same  appearance is needed when disabled
 img001
Disabled
 img002
Thanks in advance.
0
Hi Experts

Could you point a way to schedule JOBS by using Visual FoxPro, resembling in some manner MSSQLServer Agents Jobs ?

Even using VFP in conjunction with another tools.

Thanks in advance.
0
How do I tell if a record returned from a seek command is marked for deletion?


-----------------------------------------------------
set safety off

SELECT scrubFile
INDEX ON PRRecno TAG PRRecno

    USE PullFile EXCL
    SCAN ALL
      *-Search the Scrubfile based on Pullfile.PRRecno = Scrubfile.PRrecno
      IF SEEK(PRRecno, 'scrubFile')

               >> I need to add a condition here:
                       && if the scrubfile row found is not marked for deletion
                                   && Process the Pullfile record
                  && else
                         && delete the pull file record
                  && endif
                              
                        
                           
      ENDIF
    ENDSCAN
   
    *- Pack both tables
0
I need help from someone familiar with VFP "Coverage"

Concerned with how long some of my forms take to load, I've rigged it such that, in development mode, on loading any form, it will ask if I want to set coverage on and, if so, it sets coverage to (formname).csv.

To review the results I suck the csv data into a COVERAGE.DBF table ordered by METHOD and run a report which itemises every method called, how long each one runs, how many times they're called and the total time spent running any given method.

All of which works like a charm and has helped me to refactor and streamline my software.

Today I hit a problem which I don't understand.

The form I'm trying to analyse is reported as having 49 calls to its LOAD method.

This made no sense, so I inserted a global counter as first line in the method. It reported, as I expected, just one call to the method.

What am I missing?
0
Hi Experts

Could you point a way you know  to allow a multiselect combobox (or optionally ListBox) by using Visual FoxPro?

Thanks in advance
0
Hi Experts

Could you point a way to migrate data from Excel 2016 to a DBF file?

In the past Excel versions  was there an option to DBF, no longer find on Excel 2016

Thanks in advance.
0
I have a spin off question to a previous question to which Pcelba provided the perfect solution.

The scenario has changed a bit..

I have included a link to my previous question with Pcelba's perfect solution.

Previous post with solution

I am also including here the new table structures  with sample data.

A new field, clientid, has been added to the mix.

Based on clientid and the value in a descrip field in the scrub table, I need to replace that value in the scrub table with the referenced value in the label table.

For example, if clientid  in the scrub table is "1" and the corresponding descrip field in that record contains "red", the descrip field value in the scrub table needs to be updated to "Crimson".

    if the clientid in the scrub table is "2" and the corresponding descrip field contains "red", the descrip field value in the scrub table needs to be updated to "Wine".

etc, etc, etc

I have attempted to modify Pcelba's solution by adding the id field to the index and seek command.  I am getting really wacky results...

I am still using my employer's legacy VFP5 apps...

tables
0
Hi Experts

Could you point how to configure a Codepage when creating a new table by using VFP?

The code I'm using
	CREATE TABLE m.drv_local+"TAB_VEND" (;
		ITEM                 N(2),;
		SB_DISP              C(10),;
		OBRA                 C(40) ,;
		QTD                  N(2) ,;
		Custo_Un             N(8,3),;
		Custo_Tot            N(8,3))

Open in new window


When this table is created this configuration arises to the user:

img001
So I need to automatize this.

Thanks in advance
0
I have inherited a VFP5 program to maintain that is full of exception conditions with hard coded values.  

For starters, lcAbbrev (Practice Abbreviation) has nearly 200 exception conditions throughout the program:

One example of many:
do case
        case inlist(lcAbbrev,"HMT","FRY","CMU","HMP","WEB","BCV")
              APPEND from ("source\" + lcDir + ".clientattributes.csv") type delim for install <> "InstallationId" and pmstype = "Company"
        case inlist(lcAbbrev,"VVH")
              APPEND from ("source\" + lcDir + ".clientattributes.csv") type delim for install <> "InstallationId" and inlist(pmstype, "Company", "Class")
        case inlist(lcAbbrev,"S24")
              APPEND from ("source\" + lcDir + ".clientattributes.csv") type delim for install <> "InstallationId" and inlist(pmstype, "Credit")       
        case inlist(lcAbbrev,"NWT","FPW","SUF","RCY","MCA","ACO","TOM","CRD","ACA","KNL","GIS")
              APPEND from ("source\" + lcDir + ".clientattributes.csv") type delim for install <> "InstallationId" and pmstype = "Type"
        case inlist(lcAbbrev,"ACT")
              APPEND from ("source\" + lcDir + ".clientattributes.csv") type delim for install <> "InstallationId" and pmstype = "Referral"                     
        case inlist(lcAbbrev,"UPV")
              APPEND from ("source\" + lcDir + ".clientattributes.csv") type delim for install <> "InstallationId" and inlist(pmstype, "Company","ActionCode", "Class")
        otherwise
              APPEND from ("source\" + lcDir + ".clientattributes.csv") type delim for install <> "InstallationId" and …
0
OWASP: Forgery and Phishing
LVL 13
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

I need to update a table from a value in another table.

Example tables are scrub table and label table:

Scrub_lbl.jpg
Each descripion field in the scrub table needs to be matched with the descrip field in the label table and the Descrip fields (Descriptn, Descrip2, etc) need to be replaced with the value in the LabelTable.label field.

i.e. if Scrub.Descriptn = "Blue", it should be updated to "Sapphire".

If I were using SQL instead of Foxpro, the past 2 hours would have been more productive and I'd be chilling by now instead of congealing. ha.

Thank you.
0
I have been waiting patiently for 3 days for an expert solution to my problem.  I signed in this morning to discover that my question was not posted!  lol.  I must have forgot my coffee that morning.

I the meantime, I have coded something ugly that gives me what I need.  See end of this post.

Here's what I have from my original virtual post:

I have a table that looks like this:

 _table1.jpg
I need to transform the data and structure into a table that looks like this:

 _table2.jpg
I am writing a program that this code will run on each time the program is executed - in order for me to transform the current data each time ..
and for me to be able to sanely extract the information on an adhoc basis from one field rather than 9.  I think my solution is not going to be very efficient.

The original table structure (table1) is infiltrated throughout the system hundreds of times in numerous programs.  Thus I can only make this quick fix for now to facilitate the program I am working on.  

--------------------------------------------------
USE Table1
select prrecno, descriptn as descrip from Table1 where not empty(descriptn) into table ctemp
use table2
select Table2
append from ctemp

select prrecno, descrip2  as descrip from Table1 where not empty(descrip2) into table ctemp
select Table2
append from ctemp

select prrecno, descrip3  as descrip from Table1 where not empty(descrip3) into table ctemp
select Table2
append from …
0
I have 2 tables that look like this:

[embed=file 1416224

There is a 1:1 relationship based on PRRecno            
                  
The scrub file is used to fix/conform matching field names and contents in the pull file.                              

The contents of the all fields in the scrub file will replace the contents in the matching fields in the pull file.            
                  
The scrub file fields will overwrite the pull file fields, regardless of whether they are the same values or not.
                        
DefaultDir is the location of the pull file.  The pull file is the only file in the defaultDir.                              
                               
My initial thought was to get a count of the number of records based on defaultdir  in the Scrub  file that will match to the pull file.

I need more than that.  Here is my messy start:

-------------------------------------------------------------------------------------------------------------------
select defaultdir, count(*) as cnt from ckBreedScrub order by defaultdir group by defaultdir into cursor curBR1
*This gives the number of records per defaultdir ... not sure if I need this or how to get what I need
&& and/or something like this (it does not run...)
------------------------------------------------------------------------------------------------------------------

select * from ckBreedScrub order by defaultdir, prrecno into cursor curBR2

lcFName = "\PullFile.dbf"

scan                                                                                                                                  …
0
I am getting "unrecognized command verb at "or descriptn = ".

I have tried enclosing in parenthesis before the or and after.  No good.

locate  for ;
                  isdigit(substr(breed1,3,1)) ;
                  or isdigit(substr(breed1,4,1));
                  or isdigit(substr(breed1,5,1)) or empty(breed1);      
      
                or descriptn = "XXX" or descrip2 = "XXX" or descrip3 = "XXX" or descrip4 = "XXX" ;
                or descrip5 = "XXX" or descrip6 = "XXX" or descrip7 = "XXX" or descrip8 = "XXX"

This part works fine, until I add the rest of the condition:
locate  for ;
                  isdigit(substr(breed1,3,1)) ;
                  or isdigit(substr(breed1,4,1));
                  or isdigit(substr(breed1,5,1)) or empty(breed1)
0
The following code appends 4 records into ckBreedScrub, 2 are duplicates.  

There are 2 records returned from the locate.

It is repeating the same block of code on the first loop.  If I insert a RETURN command after the endif, I get only the 2 records expected.

 *************************************************
select practices
scan

if inlist(prod,"P1","P2","P0","P5") and ;
      (not upper(loop) = "C1") AND (not inlist(pracabbrev,"KEL","VIT","JBR"))

      select (lcWeekPullFileNam)


            locate  for isdigit(substr(breed1,3,1)) or isdigit(substr(breed1,4,1)) or ;
                isdigit(substr(breed1,5,1)) or empty(breed1)
                
                if found()
                        *** BREEDS THAT NEED TO BE FIXED
                      replace all verifyimg with "a" for isdigit(substr(breed1,3,1)) or isdigit(substr(breed1,4,1)) or ;
                      isdigit(substr(breed1,5,1)) or empty(breed1)
                      
                      
                    select ckBreedScrub
                        APPEND FROM (lcWeekPullFile) for verifyimg = "a"
      
            endif
                
endscan
0
I am trying to add a field to a Foxpro table, as I have done before.

The field is saved, I run the program once - no issue.  The field is populated.  Then the field disappears! And the program crashes. "Variable not Found"

I have tried it both within the Table Designer and with the following code:

USE c:\vetdata\ckBreedScrub.dbf excl
alter tABLE c:\vetdata\ckBreedScrub ADD COLUMN defaultdir c(30)

The table has 114 fields, so it is not maxed out according to Foxpro's limitations.

This is insane.  Now I am insane after 2 hours of FRUSTRATION trying to simply add a simple field!

Attached are screen shots of errors, etc.  I am baffled.  And now I've spent another 20 minutes making screen shots and posting this.  AARGH!
TableProperties1.jpg
TableProperties2.jpg
PopulatedTable.jpg
Variable-Not-Found.jpg
0

FoxPro

Visual FoxPro (VFP), and its predecessor FoxPro, is a data-centric, object-oriented, procedural, database programming language and IDE from Microsoft last released in 2007 that still has some active use due to its low cost of deployment and fairly rapid development. In 2008, Microsoft released a set of add-ons for VFP's xBase components to allow interoperability with various Microsoft technologies. It allows data processing against its native file-based data tables or database servers such as SQL Server.

Top Experts In
FoxPro
<
Monthly
>