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

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
OWASP: Avoiding Hacker Tricks
LVL 13
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

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
I am modifying a program that scans a "Practices" table.  On the second pass, Practices apparently has lost focus.

I added the ckBreedScrub table which I am opening and doing an append.  This is what has broken the code.  

The first line after the scan throws "Variable Prod is not found."  Prod is a field in Practices.


&&&*** abc code added thru 456 Denise ****************
USE c:\vetdata\templates\ckBreedScrub.dbf
select ckBreedScrub
COPY STRUCTURE TO c:\vetdata\ckBreedScrub.dbf
use
USE c:\vetdata\ckBreedScrub.dbf
select ckBreedScrub
&&&*** 456 ********************************************
      

use c:\vetdata\breedlist.dbf in 0 shared
USE c:\vetdata\breedlist.dbf IN 0 AGAIN ALIAS Breedlist_a SHARED
use c:\vetdata\remindlabels.dbf in 0 shared
use c:\vetdata\remindlabels.dbf IN 0 AGAIN ALIAS Remindlabels_a SHARED
use c:\vetdata\practices.dbf in 0 exclu
use c:\vetdata\breedmaster2.dbf in 0 exclu
use c:\vetdata\breedmaster2.dbf in 0 AGAIN ALIAS Breedmaster2_a SHARED
select breedlist_a
set order to tag ubreedd
brow last for len(alltrim(breed1))>3 nowait
select breedmaster2
set order to tag ubreedd
brow last nowait
select practices

* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SCAN
 
      if inlist(prod,"P1","P2","P0","P5") and ;     &&<< Error occurs here: "Variable Prod is not found "
      (not upper(loop) = "C1") AND (not inlist(pracabbrev,"KEL","VIT","JBR"))
 
 
      set deleted on
      USE (lcWeekPullFile) IN 0 EXCLUSIVE
      select …
0
Hi Experts

Could you point a way to automatize credit / debit cards payments by using Visual FoxPro?

Mainly a library already tested and aproved by you.

Thanks in advance!
0
i have sql table with field named arabdes with type nvarchar (100) and with arabic letter entries, i'm trying to retrieve via visual foxpro, but i keep getting ????? instead of the data itself, and the field type on my query is only character and not varchar, can anyone help me with to correctly retrieve this information correctly, thanks in advance
0
Hi Experts

Could you point a way to prevent .FRX and .FRT files corruption?

Accordingly with
It looks to be corrupted:
img001
and then, replacing with the FRX and FRT backups
img002
Thanks in advance!
0
Learn Ruby Fundamentals
LVL 13
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Hi Experts

Could you point out a routine to track the delay of the program steps during a VFP operation?

A client is complaining about the delay when saving data to .DBF (s) files. The problem is intermittent, not always occurs, just at the moment the customer push the "Save" button.

I guess Network latency is probably causing this. If so, how to workaround?

Thanks in advance.
0
In a vfp form, how do I get
      ? "Hello"
to write to the screen instead of the form?

I have tried set talk off and set console off on the form load and data environment init procedures.
0
We need to send emails from our VFP app. Currently we are calling outlook directly to do so using the following code. Ideally it would not depend on any external application and submit an email directly to a configured smtp server. If that is not an option using a generic interface that does not directly depend on outlook would still be useful. We do not need to receive email on these workstations, the mailing function should be as transparent to the user as possible, and not depend on outlook.   It will need to run on Windows Server 2012.

lnArea=SELECT()

lcBody = 'REQUEST DESCRIPTION: '+ALLTRIM(vSQLITRequests.Description)+CHR(13)+CHR(10)+CHR(13)+CHR(10)+;
			IIF(EMPTY(vSQLITRequests.Details),'','DETAILS: '+ALLTRIM(vSQLITRequests.Details)+CHR(13)+CHR(10)+CHR(13)+CHR(10))+;
			'CREATED AT: '+TTOC(vSQLITRequests.dtCreated)+CHR(13)+CHR(10)+;
			'CREATED BY: '+ALLTRIM(vSQLITRequests.CreatedBy)+CHR(13)+CHR(10)+;
			IIF(EMPTY(vSQLITRequests.ModifiedBy),'','MODIFIED AT: '+TTOC(vSQLITRequests.dtModified)+CHR(13)+CHR(10)+;
			'MODIFIED BY: '+ALLTRIM(vSQLITRequests.ModifiedBy)+CHR(13)+CHR(10))+;
			'REQUESTING EMPLOYEE: '+ALLTRIM(vSQLITRequests.RequestedBy)+CHR(13)+CHR(10)+;
			'REQUESTED COMPLETION ON OR BY DATE: '+DTOC(vSQLITRequests.dtRequestedComp)+CHR(13)+CHR(10)+;
			'PRIORITY: '+ALLTRIM(vSQLITRequests.Priority)+CHR(13)+CHR(10)+;
			'STATUS: '+ALLTRIM(vSQLITRequests.Status)+CHR(13)+CHR(10)+CHR(13)+CHR(10)+CHR(13)+CHR(10)
			
			

Open in new window

0
Hi Experts

Could you point how to workaround this mscomctl.ocx instalation on Win7?

A customer laptop using Win7 64 bits couldn't install mscomctl.ocx  with administrator privileges:

C:\Windows\SysWOW64\REGSRV32 mscomctl.ocx

Since this error occurs:
 img001
That means: maybe the module "mscomctl.ocx" doesn't be compatible with the Windows version you are using.
Check if it is compatible with one version x86(32 bits) or x64(64bits) from file regsrv32.exe

I had obtained the mscomctl.ocx from my own Win10 laptop and send it to the customer, maybe it's caused (or not) the bug.

Amazingly when running Dependency walker on my own PC, where it's correctly running,   the report is very extense... so I'm avoiding to ask the customer to do that, added the fact he will have some dificulties on this operation. I'm planning to send him a mscomctl.ocx that runs at a Win7 64bits - for another try...

Do you know any workaround on this problem, like known .DLL(s) that must exist in conjunction?

Thanks in advance!
0
I am sending parameters to a program based on user entry/selection on a form.

The variables entered in the form may look like this:

      lnWeekNum = "52"
      lcProd = "P"
      lcDate = "02/22/19"

The variable names are in a field called varpass and correspond to the variables on the form:
      varpass field = lnWeekNum, lcProd, lcDate
 

I have this working (thanks pcelba!) with this code:

SELECT varpass  FROM prodprocs WHERE procname = lcProgram INTO ARRAY laParms
*(laParms = lnWeekNum, lcProd, lcDate)
if empty(sys(2000,lcFilePath)) then
       lcMsg = lcFilePath + " does not exist *"
      Messagebox (lcMsg)
      return
 endif

IF !EMPTY(laParms[1])
  lcParams = ALLTRIM(laParms[1])
  do &lcFilePath with &lcParams

ENDIF

I need to be able to convert the variable type from a string to the data type that the called program requires.
I have added a field to the table called vartype to the table.

vartype values looks like this:
      vartype = val, str, dtoc

I think I need to add another dimension/field (varrtype) to the array containing the data type for each value in varpass.

I have added vartype to the select statement, but I haven't been able to take it any further.

SELECT varpass, vartype  FROM prodprocs WHERE procname = lcProgram INTO ARRAY laParms

I need to do these conversions based on this example:
      lnWeekNum = num(lnWeekNum)
      lcProd = str(lcProd)  .. no change
      lcDate = dtoc(lcDate)
0
Hi Experts

Could you point out the best way to install oleTreeView and oleImageList on a new laptop that uses VFP?

A form that uses these controls does not work on the new laptop, I think due to the inexistence of them.

(The same form runs perfectly on a desktop).

Thanks in advance!
0
I am getting “File does not exist” when they definitely do exist.  I have tested this endlessly.
I am testing an app that has a list of Foxpro programs in a list box.  The user selects a a program and clicks the “Run” button.
All the test programs in the list are in the same directory.  It works(ed) for one program and not the others.
To verify the validity of the path and filename:
1)      I duplicated the file names (and path) in the list that won't work, with the same file name as the one does works.  Copy and pasted.  I still get "File does not exist".  I pasted back it back over to this same one that was working – it no longer works.

     2) Programmitically wrote the location and filename to a text box before the program tries to run it.  After getting "File Does Not Exist", I  copied and pasted the text box contents into file explorer.  It opens, every time.

   3) I removed the following from my code that I thought was triggering the "file does not exist" error:
            if empty(sys(2000,lcFilePath)) then
                lcMsg = lcFilePath + " does not exist"
                Messagebox (lcMsg)
               return
         endif

         The error still occurs.   So It is not my code that triggers "File does not exist".

    4)  I added back the above IF block with an added ELSE statement:
                  if empty(sys(2000,lcFilePath)) then
                      lcMsg = lcFilePath + " does not exist **** !!!"
                    Messagebox …
0
I need a method to be able to return multiple values.

I need to send a program name to a method and have it return a list of parameters for that program based on selections and entries on a form.

do LoadParms with myProgramName


LoadParms()
parm1 = thisform.text1.value
parm2 = thisform.text2.value
parm3 = thisform.text2.value

return parm1, parm2, parm3
0
How do I get a value from a particular column of the selected row in multi column list box in VFP?

v = thisform.myListBox... ?  Value of column 2
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 am trying to capture the datetime value at the completion of a program called by a form.

The form calls the program with this code:
-------------------------------------------
if v = "load2_loopj.prg" then
       do load2_loopj.prg with lnWeekNum, cProd, cPetPics
 
endif

I have this code at the end of the load2_loopj.prg:
---------------------------------------------
      d = ttoc(datetime())
       return d

How do I capture the value of d in the form?

Is this the correct way to do this?
0
How do load a date field into a foxpro list box?

This is what i have tried:

thisform.lstProcs.AddListItem(dtoc(starttime)),lnI,4) && 3rd col
0
After uninstalling Office 2010 and installing Office 365 I cannot export to Excel from VFP.

The line
     loExcel = CREATEOBJECT("Excel.Application")
generates the error
    OLE error code 0x80040154: Class not registered.

I am seeing some suggested solutions online, but am wondering if they apply to the latest version of Office.  Locating the Office version in Excel shows
     Microsoft Excel for Office 365 MSO (16.0.11126.20234) 32-bit

Thanks in advance!
0
I am trying to streamline some old clunky VFP procs that I am having to run manually and manually edit variable values in prg's.

So ... I am loading the prg names and locations into a list box and grabbing them from there to kick off the prgs with a command button.

Too much info ..

The problem is I am getting "File Name does not exist" - not so.  

It is the same whether I get the filename from the list box and call  the it using a variable name or hard code the prg name.

Here's my code:

       vFileName = THISFORM.list1.value
      vParmName = thisform.text1.value  **not using parameter in call yet
                              *set default to "C:\Users\Denise\Dropbox\Boomerang\TestCode"
      


      *do C:\Users\Denise\Dropbox\Boomerang\TestCode\&vFileName
      ** error = "test1.prg does not exist

      do C:\Users\Denise\Dropbox\Boomerang\TestCode\test1.prg
      ** error = "test1.prg Name does not exist
0
Hi experts

I'm planning to make the user's license (just a file that remains with the .exe) of an VFP app I developed readable (and visible) only by the app and not for Windows Explorer, do you know a way to do that?

When  the app starts, the code have to check if the file is not readable  and if so, make it readable just for the app obtain license information and then to make it not readable (and visible) again.

Thanks in advance
0
Hello everyone,

I have a parameter view (lv_prname) that I am passing a name string on a VFP form.  The view is tied to a grid resource in a grid.  The view is using a "Like" sql statement.  When I pass a name value (example "TOM J", the view is not returning all the records that I have in the table.  I know I have 25 records in the table that should match, but it returns on 19 records.

My code that I am running

with thisform
do case

....
....
	case .a = 2 && processed record by name
		c = alltrim(.t1.value)
		lc_name = ALLTRIM((c)+'%')
		.Grid1.recordsource = 'lv_prcname'
		requery('lv_prcname')
		.Grid1.refresh()
		.parm2 = lc_name
		b = reccount('lv_prcname')
		.hqp = lc_name
		if b = 0
			messagebox('No Records Found',0,'Record Not Found Message')
			.cmdquit.setfocus()
			.cmdok.visible = .f.
			.refresh()
		else
			.cmdok.visible = .t.
		endif	

Open in new window



My local query view has following

SELECT * FROM payroll!payroll_tbl WHERE Payroll_tbl.fname LIKE ?lc_name ORDER BY Payroll_tbl.fname

DBSetProp(ThisView,"View","Comment","processed rec view for like names"+CHR(13))
DBSetProp(ThisView,"View","SendUpdates",.F.)
DBSetProp(ThisView,"View","BatchUpdateCount",1)
DBSetProp(ThisView,"View","CompareMemo",.T.)
DBSetProp(ThisView,"View","FetchAsNeeded",.F.)
DBSetProp(ThisView,"View","FetchMemo",.T.)
DBSetProp(ThisView,"View","FetchSize",100)
DBSetProp(ThisView,"View","MaxRecords",-1)
DBSetProp(ThisView,"View","Prepared",.F.)

Open in new window

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
>