cursor

cursor

Post by Heid » Wed, 09 Jul 2003 18:16:03


Hello,
I have program which runs in Visual Fox Pro 6, when I
compile it in Visual Fox Pro 7, I get error: Unknown
member CURSOR1. How to make it work in Fox 7?

Thanx,
Heidi
 
 
 

cursor

Post by Rick Bea » Wed, 09 Jul 2003 21:48:52

Heidi,
VFP 7.0 & 8.0, have tightened up the syntax a bit. Check your Delarations - especially LOCAL, PRIVATE and PUBLIC.
LOCAL aa, bb cc cursor1 && valid in pre VFP 7.0 - Note missing commas
now needs to be:
LOCAL aa, bb, cc, cursor1 && valid in all VFP

Rick

 
 
 

cursor

Post by YmlqYW » Mon, 22 May 2006 18:21:01

I wrot these codes to get a report from a cursor but when I run this code it
give a report from table pic how I can get report from cursor(ho) I made from
pic
Thank you


SELECT a
USE pic
avvv=ALLTRIM(name(

SELECT * FROM pic WHERE avvv $ name INTO CURSOR ho READWRITE
GO top
DO while NOT EOF()
REPLACE num WITH ALLTRIM(num)+'.jpg'
SKIP
enddo

REPORT FORM r.frx PREVIEW
 
 
 

cursor

Post by Olaf Dosch » Mon, 22 May 2006 19:28:44

> I can get report from cursor(ho) I made from


SELECT ho
REPORT FORM r.frx PREVIEW

Did you specify the table in the reports dataenvironment?
Then don't do so, and don't use tablenam.fieldname
as the controlsource of the report controls, simply
reference fieldnames.

Then the report will simply take the alias of the
current workarea as it's datasource.

Bye, Olaf.
 
 
 

cursor

Post by AA » Mon, 22 May 2006 22:03:25

Bijan
You'd better not use code like SELECT a or SELECT b. It's not done any more.
If you want to open a table in an free workarea write:
IF NOT USED('table')
SELECT 0
USE Table AGAIN ALIAS table
ELSE
SELECT Table
ENDIF
or
USE table AGAIN ALIAS alias IN 0

The SQL command SELECT .. INTO CURSOR x always puts the query result cursor
in a free workarea. And you don't need to open the source table first. The
query can manage opening its source tables if the ycan be found in the
current SET PATH or SET DEFAULT path.
-Anders



"bijan" < XXXX@XXXXX.COM > skrev i meddelandet
 
 
 

cursor

Post by Cindy Wine » Tue, 23 May 2006 06:34:47

Hi Bijan,

Just to add something no one else has mentioned, check out SCAN...END SCAN
as a replacement for DO WHILE...SKIP...ENDDO. Even better than that, you can
use the ALL keyword in a REPLACE statement to take care of all records in
your cursor. No need for SCAN or DO WHILE if you use REPLACE ALL. Finally,
you can make your changes right in a SQL SELECT statement, although you'll
need to either list all the fields you need in your select statement or give
your modified field another name.

Select PicNumber, Name, ALLT(Num) + ".jpg" As Num ;
From Pic Into Cursor Ho ReadWrite ;
Where Avv $ Name ;
Order By SomeField

*-- Or
Select *, ALLT(Num) + ".jpg" As NewNum ;
From ......

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
 
 
 

cursor

Post by Dan Freema » Wed, 24 May 2006 00:15:19

I would NOT recommend using ALLT() in the output list for a query.
Particularly for someone struggling with basics.

The resulting column will take on the width of the first row encountered.
Remaining rows may be truncated if the contents are longer than the first,
and then we're right back at "I have a problem I don't understand".

Dan
 
 
 

cursor

Post by Jay » Wed, 24 May 2006 00:38:13

i wouldnt use the phrase:
ALLT(Num) + ".jpg" As Num
in a SELECT because that may cause a premature truncation of the column

instead i would use use:
transform(num,'@L 999999')+'.jpg' as num
 
 
 

cursor

Post by Cindy Wine » Wed, 24 May 2006 08:31:33

Create Cursor Test (Num C(20))
Insert Into Test Values ("123")
Select ;
Transform(Num,'@L 999999')+'.jpg' as Num ;
From Test

? Num && "123 .jpg"

*-- A better way is
Select ;
PadR(Alltrim(Num) + ".jpg", 20) As Num ;
From Test

? Num && "123.jpg "

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
 
 
 

cursor

Post by Cindy Wine » Wed, 24 May 2006 08:47:24

Make that PadR(Alltrim(Num) + ".jpg", 24) .

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
 
 
 

cursor

Post by Jay » Wed, 24 May 2006 10:53:09

sorry cindy, i beg to differ.
you missed the @L in the transform, which left fills with zeroes.
my pic would be 000123.jpg

but of course , right padding with spaces is also fine, it all depends
on how the user wants to store the pic num.

There is always more than one way to accomplish somthing with Fox!
 
 
 

cursor

Post by Mark Burgu » Wed, 24 May 2006 16:45:17

I know you have already had a lot of response, but i think your problem is
that you have not done a select ho just before doing the report preview as a
result the pic cursor is still the currently selected cursor, unless as
someone suggested you had added it to the datasource of the report.

a very helpful book on the report writer is
http://www.yqcomputer.com/
trying to learn about foxpro Report writing.
 
 
 

cursor

Post by Cindy Wine » Wed, 24 May 2006 23:34:19

If you noticed in my example (see below) I didn't get "000123.jpg" but
rather "123 .jpg" As a side note, when I set m.Num to "123" and issue
"transform(m.num,'@L 999999')+'.jpg'" in the Watch window I get "123.jpg" .

What do you get in the Watch window when you create an m.Num variable, and
what do you get when you run my code below? Off the top of my head I can't
think of any settings that affect this.


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
 
 
 

cursor

Post by Fred Taylo » Thu, 25 May 2006 00:27:16

If m.num is character ("123 "), then the "@L 999999999" will have no
effect in the transform. It must be a numeric value.

--
Fred
Microsoft Visual FoxPro MVP
 
 
 

cursor

Post by Jay » Thu, 25 May 2006 00:37:50

that the problem, you're right!
num is a character string in the example, so alltrim is needed.
transform will not work.
i assumed num was numeric.
i'm just so used to doing things a certain way.