Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with DataToClip Method
Message
 
 
To
31/05/2001 12:22:37
Richard Williams
State of Ohio, Dept. of Development
Columbus, Ohio, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513234
Message ID:
00513257
Views:
14
>Hi Mark, I've got the help datatoclip method in front of me, but I am having trouble with the syntax. ie ApplicationObject.DatToClip([nWorkArea|cTableAlias](,nRecords][,nClipFormat])
>what is my ApplicationObject? I tried thisform.txtLast_Name.DataToClip, but FoxPro sees this as a property not a method. Thanks Rick

Do you have Hacker's Guide? Here is the quote:
Example oVFP = createobject("visualfoxpro.application")
oVFP.Visible = .T. && so we can see it
* Change the background so we can tell the two apart.
oVFP.DoCmd("_SCREEN.BackColor = RGB(64,128,128)")
oVFP.DoCmd("USE [C:\Program Files\DevStudio\" + ;
"VFP\Samples\Data\Customer]")
? oVFP.Eval("DATE()") && returns DATETIME()! not date
oVFP.SetVar("lnRecCount",oVFP.Eval([RECCOUNT("CUSTOMER")]))
? oVFP.Eval("lnRecCount") && shows 92 records

Usage uResult = oApp.DataToClip( [ cAlias | nWorkArea ]
[, nNumberOfRecords ]
[, nDataFormat ])
aArray = oApp.RequestData( [ cAlias | nWorkarea ]
[, nNumberOfRecords ] )


Parameter
Value
Meaning

cAlias
Character
The alias from which to gather data.

Omitted
If nWorkArea is also omitted, gather data from the current work area.

nWorkArea
Numeric
The work area from which to gather data.

Omitted
If cAlias is also omitted, gather data from the current work area.

nNumberOfRecords
Numeric
The number of records to place on the clipboard or in the array.

Omitted
Put one record on the clipboard or in the array.

nDataFormat
1 (or 2) or omitted
Separate fields with spaces.

3
Separate fields with tabs.

aArray
Array
An array to hold the specified records.

uResult
Numeric
The number of records returned.

Character
The empty string. Returned only when the specified cAlias is not used or nWorkArea has no table open.


These two methods are quite similar. They both grab one or more records from an open table and do something with them. DataToClip puts them on the clipboard, while RequestData stores them in an array. In both cases, though, you're left with data that you can manipulate from within another application.

Both methods have one confusing piece of syntax. Although all their parameters are optional, you still need placeholders to omit them. That is, even if you want to use the current work area, you need to put in the comma that precedes the number of records—otherwise, the number is interpreted as a work area number.

DataToClip gives you a choice of output format. Omitting the format or specifying 1 (or the undocumented 2) pads each field with spaces to its full size. Giving a format of 3 pads the fields as needed, then puts a tab between each pair of fields.

Example * Continuing from the example above
? oVFP.DataToClip() && shows 92 records copied
aData = oVFP.RequestData() && Loads aData with records
? ALEN(aData) && 1104 elements
? ALEN(aData,1) && 92 rows
? ALEN(aData,2) && 12 fields each
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform