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

Use A   && many records long

DO WHILE not eof()

      COPY NEXT 1 to bbb  && yes, it just keeps creating this one record file over and over

END DO





fails in when BBB is located on a network drive for some networks and works if BBB is located on the C drive. Why would that be? Could it be SMB1, 2 related?
0
C++ 11 Fundamentals
LVL 19
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

I am using foxypreviewer to automate unattended invoice emailing.  The attended mode works fine but I have not been able to identify the location of the settings so that I can enter them automatically.  The foxypreviewer settings dbf identifies the names but setting those values including scattering them to mem does nothing to the process?
what is the location that foxypreviewer reads the email settings from?
0
Any idea why I am suddenly getting these errors when building executables?  I have SetStrictDate to 2 Constants Plus CTOD() AND CTOT().  These are two of the many errors I am getting.  CTOD AND CTOT is used throughout the applications.


Compiling s:\centerpoint\is\source\deshipman.scx
ldDateRun = CTOD(ldDateRun)
Error in line 13 of frmdeShipMan.cmndEmail.Click (record 13): CTOD and CTOT can produce incorrect results. Use DATE(y,m,d) or DATETIME(y,m,d,h,mm,s) instead, or recompile with STRICTDATE less than 2.

Compiling s:\centerpoint\is\classes\wscalendar.vcx
Thisform.CurrentDate=ctod(cMonth+'/'+cDay+'/'+cYear)
Error in line 7 of ws_calendar.oleCalendar.AfterUpdate (record 3): CTOD and CTOT can produce incorrect results. Use DATE(y,m,d) or DATETIME(y,m,d,h,mm,s) instead, or recompile with STRICTDATE less than 2.
0
Hi Experts

Could you clear from where the VFP date()  function obtains the current date?

Accordingly with:
img001
The date used at printer is different from the Windows date (correct).

The user said me the BIOS date is incorrect, does the date used by the printer comes from BIOS?

Thanks in advance.
0
I need to export data from a VFP9 table to an .xls file.
One field in the xls file will be receiving two address lines, and needs the ALT Enter Code to create a CR/LF.
Can I put that code in the export file--
e.g.
select  Line1 + ?? + Line 2 as address1

Alternatively can I export something like "xy" to mark the break and then search and replace in the xlsx?. Seems simple but when I use CTRL J or ALT 0010 as the replace character, I end up with a blank line between Line 1 and Line 2.
0
I have an application that is being tested by a co-worker.  Twice he has received "record out of range" error.  I have never gotten the error.

I have done extensive testing and modifications on my local machine with no error.  

We are also both testing the Foxpro app  remotely from our computers, connected to a server where the app will reside and run.

Here is a screen shot of the error from my coworker:

ckbreeds-error.png
I suspect it is an issue with the remindlabes_um(dbf) CDX file.

I am copying the dbf and cdx files directly from the live environment to my test environment along with a number of other large dynamic "work tables" that are updated weekly.  Do I need to reindex them each time I copy them to Test? ... Is reindexing something that needs to be done routinely?
0
I have a table that looks like this:

  0Table.jpg
For any record that has one of the descrip fields empty, I need to fill it with the value of the descrip field in the next column to the right and move the others over, if any.

If only the first field, decriptn is populated, the record gets deleted.

The result will look like this:

0Table2.png
What's the best way to do this?
0
Connecting VFP Database File to Excel (pivot table).
Dears,

I have a table in Visual Foxpro 9 that is being updated daily.
I would like to create a pivot table in Excel based on this table.

These are the steps I am following - but it is not working.. Please help.

1-Go to ODBC connection. Create a new one. Based on "Microsoft Dbase-Driver (*.dbf) _- Setup the name (DataCon) - Select version DBase IV - Select the directory where the Table is
2-go to excel - create a new document- Click on insert Pivot Table - Click on Choose connection -Browse for More-New source-ODBC DSN -Next - Select DataCon-Next- Select the table - raw-Name the connection (test.odc)-Finish
It gives me "ODBC DBase Driver - External Table is not in the expected format !
0
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
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
Announcing the Winners!
LVL 19
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

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
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
Build an E-Commerce Site with Angular 5
LVL 19
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

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

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
>