Report can be used only to output the data from tables / cursors.
If the main table has no records, the report only flashes.
To output some text or the values from some memory variables, not related to any tables :
1 Create a new report
2 View-> Data Environment (or Right click and choose Data Environment)
3 In the Init event of Data Environment type
CREATE CURSOR (SYS(2015)) (ii I)
APPEND BLANK
Now the report has a cursor.
To output only some text, add a label control to this report and type the desired text.
The result
The values of private or public memory variables can also be displayed.
The result
Faceți căutări pe acest blog
luni, 23 februarie 2015
miercuri, 18 februarie 2015
No more than n detail per report page
If the table / cursor isn't indexed, add a group with the expression
If the table / cursor is indexed, first add a report variable variablename with
See http://www.tek-tips.com/faqs.cfm?fid=7718
FLOOR((RECNO()-1)/n)
and check group starts on new pageIf the table / cursor is indexed, first add a report variable variablename with
Reset value based on: = Report
and
Calculation type: = Count
Then add a group with the expression
FLOOR(variablename/n)
and check group starts on new pageSee http://www.tek-tips.com/faqs.cfm?fid=7718
marți, 10 februarie 2015
Export pptx 1.4
Export the data displayed in a grid, or the data contained by a table / cursor to PowerPoint 2007+ format
Download link
http://www.foxite.com/uploads/c5b3ffa7-7252-4987-92dd-400d44c51145.zip
Properties:
a) To export the data displayed in a grid (only the visible columns)
Drop an instance of the exportpptx class to your form and set :
- grid=grid reference
- label (optional)=the default file name; a reference to an object with the "caption" property; by default DATETIME()
b) To export the data contained in a table / cursor
Drop an instance of the exportpptx class to your form and set :
- grid=table / cursor name
- label (optional)=the default file name; a reference an object with the "caption" property; by default DATETIME()
- cFields (optional)= list of fields to be displayed, separated by commas; by default all the fields are exported
- cHeaders (optional)= list of field headers to be displayed, separated by commas; by default the field names
c) Formatting properties (right click)
headbackcolor=back color for column headers (if >=0)
headfontbold= .T./.F.
headfontitalic= .T./.F.
headfontname=if not empty and installed
headfontsize=if>0
headforecolor=font color for column headers (if >=0)
rowbackcolor=back color for rows (if >=0)
rowfontbold= .T./.F.
rowfontitalic= .T./.F.
rowfontname=if not empty and installed
rowfontsize=if>0
rowforecolor=font color for rows (if >=0)
slide transition
the possibility to add a single picture (the same on all slides)
table styles
See http://www.foxite.com/archives/dbf2pptx-0000415404.htm
Related posts
http://praisachion.blogspot.com/2016/06/inspectpptx-10.html
http://praisachion.blogspot.com/2016/06/inspectdocx-10.html
MSOffice -> DBF
http://praisachion.blogspot.com/2017/08/importfromxlsx-40.html
http://praisachion.blogspot.com/2017/06/append-from-xlsx-30.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-34.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-33.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-32-appendfromxlsx-21.html
http://praisachion.blogspot.com/2016/06/appendfrompptx-10.html
http://praisachion.blogspot.com/2016/06/appendfromdocx-21.html
http://praisachion.blogspot.com/2016/06/importfromdocx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-11.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-10.html
http://praisachion.blogspot.com/2016/06/importfromdocx-30.html
http://praisachion.blogspot.com/2016/05/importfromxlsx-22.html
http://praisachion.blogspot.com/2016/02/import-dbf-from-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/importfromdocx-20.html
http://praisachion.blogspot.com/2016/01/appendfromdocx-20.html
http://praisachion.blogspot.com/2016/01/importfromxlsx-13.html
http://praisachion.blogspot.com/2016/01/appendfromxlsx-20.html
http://praisachion.blogspot.com/2015/12/appendfromxlsx-15.html
http://praisachion.blogspot.com/2015/11/importfromxlsx-13.html
http://praisachion.blogspot.com/2015/09/importfromxlsx-12.html
http://praisachion.blogspot.com/2015/09/appendfromxlsx-14.html
http://praisachion.blogspot.com/2015/09/appendfromnxlsx-13.html
http://praisachion.blogspot.com/2015/08/importfromxlsx-11.html
http://praisachion.blogspot.com/2015/07/import-from-xlsx.html
http://praisachion.blogspot.com/2015/07/insert-from-focx.html
http://praisachion.blogspot.com/2015/06/append-from-docx.html
DBF -> MSOffice
Dbf2Xlsx6 4.2 (VFP6)
http://praisachion.blogspot.com/2017/04/export-dbf-to-excel-2007.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msexcel-xlsx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-mspowerpoin-pptx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msword-docx.html
http://praisachion.blogspot.com/2016/11/export-to-xlsx.html
http://praisachion.blogspot.com/2016/11/export-to-pptx.html
http://praisachion.blogspot.com/2016/11/export-to-docx.html
http://praisachion.blogspot.com/2016/11/export-from-vfp6-to-msoffice-docx-pptx.html
http://praisachion.blogspot.com/2016/09/copytoxlsx6-10.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx_24.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/exporttopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttodocx-20.html
http://praisachion.blogspot.com/2016/01/copytopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttoxlsx-20.html
http://praisachion.blogspot.com/2016/01/copytoxlsx-30.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-19-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-210-procedure.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-18-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-29.html
http://praisachion.blogspot.com/2015/02/export-pptx-13.html
http://praisachion.blogspot.com/2015/01/copytodocx-12.html
http://praisachion.blogspot.com/2015/01/exportdocx-1.html
OOffice -> DBF
http://praisachion.blogspot.com/2016/11/import-from-openoffice-libreoffice-for.html
http://praisachion.blogspot.com/2016/09/importfromoowrtext-10.html
http://praisachion.blogspot.com/2016/09/importfromooffice-1o.html
http://praisachion.blogspot.com/2016/08/importfromoocalc.html
DBF -> OOffice
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_52.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_16.html
http://praisachion.blogspot.com/2016/09/copy-to-ods-10-openoffice-calc.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice.html
http://praisachion.blogspot.com/2016/09/copy-to-odt-10.html
Download link
http://www.foxite.com/uploads/c5b3ffa7-7252-4987-92dd-400d44c51145.zip
Properties:
a) To export the data displayed in a grid (only the visible columns)
Drop an instance of the exportpptx class to your form and set :
- grid=grid reference
- label (optional)=the default file name; a reference to an object with the "caption" property; by default DATETIME()
b) To export the data contained in a table / cursor
Drop an instance of the exportpptx class to your form and set :
- grid=table / cursor name
- label (optional)=the default file name; a reference an object with the "caption" property; by default DATETIME()
- cFields (optional)= list of fields to be displayed, separated by commas; by default all the fields are exported
- cHeaders (optional)= list of field headers to be displayed, separated by commas; by default the field names
c) Formatting properties (right click)
headbackcolor=back color for column headers (if >=0)
headfontbold= .T./.F.
headfontitalic= .T./.F.
headfontname=if not empty and installed
headfontsize=if>0
headforecolor=font color for column headers (if >=0)
rowbackcolor=back color for rows (if >=0)
rowfontbold= .T./.F.
rowfontitalic= .T./.F.
rowfontname=if not empty and installed
rowfontsize=if>0
rowforecolor=font color for rows (if >=0)
slide transition
the possibility to add a single picture (the same on all slides)
table styles
See http://www.foxite.com/archives/dbf2pptx-0000415404.htm
Related posts
http://praisachion.blogspot.com/2016/06/inspectpptx-10.html
http://praisachion.blogspot.com/2016/06/inspectdocx-10.html
MSOffice -> DBF
http://praisachion.blogspot.com/2017/08/importfromxlsx-40.html
http://praisachion.blogspot.com/2017/06/append-from-xlsx-30.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-34.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-33.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-32-appendfromxlsx-21.html
http://praisachion.blogspot.com/2016/06/appendfrompptx-10.html
http://praisachion.blogspot.com/2016/06/appendfromdocx-21.html
http://praisachion.blogspot.com/2016/06/importfromdocx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-11.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-10.html
http://praisachion.blogspot.com/2016/06/importfromdocx-30.html
http://praisachion.blogspot.com/2016/05/importfromxlsx-22.html
http://praisachion.blogspot.com/2016/02/import-dbf-from-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/importfromdocx-20.html
http://praisachion.blogspot.com/2016/01/appendfromdocx-20.html
http://praisachion.blogspot.com/2016/01/importfromxlsx-13.html
http://praisachion.blogspot.com/2016/01/appendfromxlsx-20.html
http://praisachion.blogspot.com/2015/12/appendfromxlsx-15.html
http://praisachion.blogspot.com/2015/11/importfromxlsx-13.html
http://praisachion.blogspot.com/2015/09/importfromxlsx-12.html
http://praisachion.blogspot.com/2015/09/appendfromxlsx-14.html
http://praisachion.blogspot.com/2015/09/appendfromnxlsx-13.html
http://praisachion.blogspot.com/2015/08/importfromxlsx-11.html
http://praisachion.blogspot.com/2015/07/import-from-xlsx.html
http://praisachion.blogspot.com/2015/07/insert-from-focx.html
http://praisachion.blogspot.com/2015/06/append-from-docx.html
DBF -> MSOffice
Dbf2Xlsx6 4.2 (VFP6)
http://praisachion.blogspot.com/2017/04/export-dbf-to-excel-2007.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msexcel-xlsx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-mspowerpoin-pptx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msword-docx.html
http://praisachion.blogspot.com/2016/11/export-to-xlsx.html
http://praisachion.blogspot.com/2016/11/export-to-pptx.html
http://praisachion.blogspot.com/2016/11/export-to-docx.html
http://praisachion.blogspot.com/2016/11/export-from-vfp6-to-msoffice-docx-pptx.html
http://praisachion.blogspot.com/2016/09/copytoxlsx6-10.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx_24.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/exporttopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttodocx-20.html
http://praisachion.blogspot.com/2016/01/copytopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttoxlsx-20.html
http://praisachion.blogspot.com/2016/01/copytoxlsx-30.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-19-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-210-procedure.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-18-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-29.html
http://praisachion.blogspot.com/2015/02/export-pptx-13.html
http://praisachion.blogspot.com/2015/01/copytodocx-12.html
http://praisachion.blogspot.com/2015/01/exportdocx-1.html
OOffice -> DBF
http://praisachion.blogspot.com/2016/11/import-from-openoffice-libreoffice-for.html
http://praisachion.blogspot.com/2016/09/importfromoowrtext-10.html
http://praisachion.blogspot.com/2016/09/importfromooffice-1o.html
http://praisachion.blogspot.com/2016/08/importfromoocalc.html
DBF -> OOffice
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_52.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_16.html
http://praisachion.blogspot.com/2016/09/copy-to-ods-10-openoffice-calc.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice.html
http://praisachion.blogspot.com/2016/09/copy-to-odt-10.html
luni, 9 februarie 2015
API Messagebox
VFP's native Messagebox() has some limitations.
1 The maximum length of the message is 1024 (it appears that characters after the 1024th are truncated)
MessageBox(SPACE(1023)+"123", "Message title", 0)
2 Unicode characters cannot be showed
3 Other limitations
API Messagebox() is easy to be used and has no such restrictions.
There are two type of messageboxes:
- MessageBoxA, useful for ASCII messages
- MessageBoxW, useful for Unicode messages
1 In the first example, is shown a message, with more than 1024 characters:
DECLARE INTEGER MessageBoxA IN user32;
INTEGER hWindow, STRING lpText,;
STRING lpCaption, LONG uType
= MessageBoxA(_screen.HWnd, SPACE(5000)+"123", "Message title", 0)
2 The second example contains another set of buttons (6)
DECLARE INTEGER MessageBoxA IN user32 INTEGER hWindow, STRING lpText,STRING lpCaption, LONG uType
= MessageBoxA(_screen.HWnd, "Well ?"+CHR(13)+"Oh, no, no, no!", "Message title", 6)
3 The window shown in front of all windows from your desktop (WS_EX_TOPMOST style => 0x1000)
DECLARE INTEGER MessageBoxA IN user32 INTEGER hWindow, STRING lpText,STRING lpCaption, LONG uType
= MessageBoxA(_screen.HWnd, "Well ?", "Message title", 0x1000)
This style can be applied even to VFP messagebox:
MESSAGEBOX("AAAAA !",0x1000)
4 The ability to display Unicode characters.
To achieve this, instead of MessageBoxA must be used MessageBoxW.
The message and the title are strings ended with a CHR(0).
Regular text must be converted with STRCON(...,5), but can be used Unicode characters as a blob constant. (See http://www.news2news.com/vfp/?function=73)
Example for regular text
DECLARE INTEGER MessageBoxW IN user32 INTEGER hWindow, STRING lpText, STRING lpCaption, LONG uType
= MessageBoxW(_screen.HWnd, STRCONV("Well ?"+CHR(13)+"Oh, no, no, no!"+CHR(0),5), STRCONV("Message title"+CHR(0),5), 0)
Examples for blob constant (for Unicode, see http://unicode-table.com/en/)
Character "0" is Unicode 0x0030. As blob constant will be written 0h3000 (note the reversed order of the two bytes). Because the string must be ended with a CHR(0), displaying a "0" become :
DECLARE INTEGER MessageBoxW IN user32 INTEGER hWindow, STRING lpText, STRING lpCaption, LONG uType
= MessageBoxW(_screen.HWnd, 0h300000, STRCONV("Message title"+CHR(0),5), 0)
To display "01", the blob constant will be 0h3000310000, where 3000 is Unicode "0", 3100 is Unicode "1" and 00 is the string terminator.
DECLARE INTEGER MessageBoxW IN user32 INTEGER hWindow, STRING lpText, STRING lpCaption, LONG uType
= MessageBoxW(_screen.HWnd, 0h3000310000, STRCONV("Message title"+CHR(0),5), 0)
Note that some characters might not be displayed.
Another Unicode message.
DECLARE INTEGER MessageBoxW IN user32 INTEGER hWindow, STRING lpText, STRING lpCaption, LONG uType
= MessageBoxW(_screen.HWnd, 0h26094709350940092E09470935093E0900, STRCONV("Message title"+CHR(0),5), 0)
See http://www.tek-tips.com/viewthread.cfm?qid=1743552
1 The maximum length of the message is 1024 (it appears that characters after the 1024th are truncated)
MessageBox(SPACE(1023)+"123", "Message title", 0)
2 Unicode characters cannot be showed
3 Other limitations
API Messagebox() is easy to be used and has no such restrictions.
There are two type of messageboxes:
- MessageBoxA, useful for ASCII messages
- MessageBoxW, useful for Unicode messages
1 In the first example, is shown a message, with more than 1024 characters:
DECLARE INTEGER MessageBoxA IN user32;
INTEGER hWindow, STRING lpText,;
STRING lpCaption, LONG uType
= MessageBoxA(_screen.HWnd, SPACE(5000)+"123", "Message title", 0)
2 The second example contains another set of buttons (6)
DECLARE INTEGER MessageBoxA IN user32 INTEGER hWindow, STRING lpText,STRING lpCaption, LONG uType
= MessageBoxA(_screen.HWnd, "Well ?"+CHR(13)+"Oh, no, no, no!", "Message title", 6)
3 The window shown in front of all windows from your desktop (WS_EX_TOPMOST style => 0x1000)
DECLARE INTEGER MessageBoxA IN user32 INTEGER hWindow, STRING lpText,STRING lpCaption, LONG uType
= MessageBoxA(_screen.HWnd, "Well ?", "Message title", 0x1000)
This style can be applied even to VFP messagebox:
MESSAGEBOX("AAAAA !",0x1000)
4 The ability to display Unicode characters.
To achieve this, instead of MessageBoxA must be used MessageBoxW.
The message and the title are strings ended with a CHR(0).
Regular text must be converted with STRCON(...,5), but can be used Unicode characters as a blob constant. (See http://www.news2news.com/vfp/?function=73)
Example for regular text
DECLARE INTEGER MessageBoxW IN user32 INTEGER hWindow, STRING lpText, STRING lpCaption, LONG uType
= MessageBoxW(_screen.HWnd, STRCONV("Well ?"+CHR(13)+"Oh, no, no, no!"+CHR(0),5), STRCONV("Message title"+CHR(0),5), 0)
Examples for blob constant (for Unicode, see http://unicode-table.com/en/)
Character "0" is Unicode 0x0030. As blob constant will be written 0h3000 (note the reversed order of the two bytes). Because the string must be ended with a CHR(0), displaying a "0" become :
DECLARE INTEGER MessageBoxW IN user32 INTEGER hWindow, STRING lpText, STRING lpCaption, LONG uType
= MessageBoxW(_screen.HWnd, 0h300000, STRCONV("Message title"+CHR(0),5), 0)
To display "01", the blob constant will be 0h3000310000, where 3000 is Unicode "0", 3100 is Unicode "1" and 00 is the string terminator.
DECLARE INTEGER MessageBoxW IN user32 INTEGER hWindow, STRING lpText, STRING lpCaption, LONG uType
= MessageBoxW(_screen.HWnd, 0h3000310000, STRCONV("Message title"+CHR(0),5), 0)
Note that some characters might not be displayed.
Another Unicode message.
DECLARE INTEGER MessageBoxW IN user32 INTEGER hWindow, STRING lpText, STRING lpCaption, LONG uType
= MessageBoxW(_screen.HWnd, 0h26094709350940092E09470935093E0900, STRCONV("Message title"+CHR(0),5), 0)
See http://www.tek-tips.com/viewthread.cfm?qid=1743552
duminică, 8 februarie 2015
Report was sent to printer
With SET REPORTBEHAVIOR 80 is easy to check if a report was sent to printer (directly or via preview)
SYS(2040) is very useful, but its value is relevant only inside the report. So SYS(2040) will be saved into a private or public memory variable, from one of the Summary band events, or Page footer band events.
Example: at ON Entry in the Page Footer Band, place :
In the calling procedure / method:
...
SYS(2040) is very useful, but its value is relevant only inside the report. So SYS(2040) will be saved into a private or public memory variable, from one of the Summary band events, or Page footer band events.
Example: at ON Entry in the Page Footer Band, place :
_vfp.setvar("MyFlag",sys(2040))
where MyFlag is a private or a public variableIn the calling procedure / method:
...
PUBLIC MyFlag
MyFlag="0"
REPORT FORM ...
DO CASE
CASE MyFlag="1"
MESSAGEBOX("Report is in Preview Mode")
CASE MyFlag="2"
MESSAGEBOX("Report is being sent as output (such as a printer or file).")
ENDCASE
See http://www.foxite.com/archives/report-has-been-sent-to-printer-0000379723.htm
joi, 5 februarie 2015
Typing characters programmatically, by invoking the keypress event
Unlike other events (click or interactivechange), if keypress is programmatically invoked, the code is executed but the characters are not "typed".
But with a little trick, this can be surpassed.
Add a third parameter (logical) in the keypress event .
If this third parameter is .T., then call DODEFAULT() followed by =This.Value.
See
http://www.tek-tips.com/faqs.cfm?fid=7702
Related links
[1] "Typing" characters programatically (2)
[2] "Typing" characters programatically (3)
[3] "Typing" characters programatically (4)
But with a little trick, this can be surpassed.
Add a third parameter (logical) in the keypress event .
If this third parameter is .T., then call DODEFAULT() followed by =This.Value.
Public ofrm ofrm=Createobject("MyForm") ofrm.Show() Define Class MyForm As Form Add Object txt As MyText Add Object cmd As CommandButton With ; Left=150,; Caption='Select any row from grid and click',; AutoSize=.T. Add Object grd As Grid With Top=50 Procedure Init Local lni * Preparing the grid Create Cursor cChar (cChar C(10)) For lni=1 To 5 Insert Into cChar Values (Chr(64+m.lni)) Next Insert Into cChar Values ('Two words') Go Top This.grd.RecordSource='cChar' This.grd.column1.Width=100 Endproc Procedure cmd.Click Local lni,lcStr lcStr=Alltrim(cChar.cChar) For lni=1 To Len(m.lcStr) Thisform.txt.KeyPress(Asc(Substr(m.lcStr,m.lni,1)),0,.T.) Next Endproc Enddefine ********************* * Text box class ********************* Define Class MyText As TextBox Procedure KeyPress Lparameters nKey,nShift,lraised If lraised DoDefault(nKey,nShift) =This.Value Endif Endproc Enddefine
See
http://www.tek-tips.com/faqs.cfm?fid=7702
Related links
[1] "Typing" characters programatically (2)
[2] "Typing" characters programatically (3)
[3] "Typing" characters programatically (4)
luni, 2 februarie 2015
FastXTab version 1.6
A crosstab class.
This is an enhanced version of the FastxTab class, created by Alexander Golovlev.
The original class can be found here http://www.universalthread.com/ViewPageNewDownload.aspx?ID=9944
There are many extensions, like formula for every element and multiple cells.
Download from :
Properties
1 Input cursor / table - lCloseTable .T. the cursor / table which holds the data source is closed 2 Output cursor / table - lCursorOnly .T. The result is stored in a cursor, otherwise in a free table - cOutFile Name of the cursor / table which holds the result - lDisplayNulls .T. / .F. => Set null ON / OFF - lBrowseAfter Specifies whether to open a Browse window on the cross tab output 3 CrossTab a) Rows - cRowField Field name / Field expression for rows (group) - nRowField Field position (row number in AFIELDS(,cSource)) for rows (group) - cPageField (optional) Field name / Field expression for rows supergroup - nPageField Field position (row number in AFIELDS(,cSource)) for rows supergroup b) Columns - cColField Field name / Field expression for columns (group) - nColField Field position (row number in AFIELDS(,cSource)) for columns (group) c) When each column field holds a single data (cell) column - cDataField Field name for cells - nDataField Field position (row number in AFIELDS(,cSource)) for cells - nFunctionType Aggregate function used for cells 1 Sum 2 Count 3 Avg 4 Min 5 Max 6 Custom - cFunctionExp The expression used for cells, When nFunctionType=6 Ignored if nFunctionType<>6 d) Some columns contains more than a single data (cell) column - nMultiDataField (default=1) Number of data (cell) columns - acDataField Array with field names for cells - anDataField Array with field positions (row number in AFIELDS(,cSource)) for cells - anFunctionType Array with aggregate functions used for cells 1 Sum 2 Count 3 Avg 4 Min 5 Max 6 Custom - acFunctionExp Array with the expressions used for cells, When anFunctionType()=6 e) Miscelaneous - nAvePrec Decimal precision when nFunctionType = 3 (average) - cCondition Expression for a where condition - cHaving Expression for a having condition - nRowField2 When nRowField2 = 0 and !empty(cRowField), fastxtab distribute cells by columns and rows (accoding to cRowField and cColField) Ignored When nRowField2 # 0 or empty(This.cRowField) - lTotalRows When .T. a supplementary row with totals is added Notes There are three type of outputs 1) When nRowField2 = 0 and !empty(cRowField), fastxtab distribute cells by columns and rows (accoding to cRowField and cColField) ; no aggregate functions are performed If nFunctionType / anFunctionType = 6, cells contains the expression from cFunctionExp / acFunctionExp Otherwise, cells contains the field from cDataField 2) When nRowField = 0 and EMPTY(cRowField), fastxtab distribute cells by columns (accoding to cColField) ; no aggregate functions are performed If nFunctionType / anFunctionType = 6, cells contains the expression from cFunctionExp / acFunctionExp Otherwise, cells contains the field from cDataField 3) Otherwise fastxtab applies aggregate functions and distribute results by columns and rows (accoding to cPageField, cRowField and cColField) If nFunctionType / anFunctionType = 1, cells contains SUM(cDataField) If nFunctionType / anFunctionType = 2, cells contains COUNT(cDataField) If nFunctionType / anFunctionType = 3, cells contains AVERAGE(cDataField) If nFunctionType / anFunctionType = 4, cells contains MAX(cDataField) If nFunctionType / anFunctionType = 5, cells contains MIN(cDataField) If nFunctionType / anFunctionType = 6, cells contains the expression from cFunctionExp / acFunctionExp (must be a valid expression from the point of the aggregation)
Examples
Demo 1
A table with inputs and outputs from some companies for each year. RAND(-1) CREATE CURSOR cTest (cName C(10),nYear I,nInput N(10,2),nOutput N(10,2)) FOR lnC=1 TO 5 FOR lnY=2010 TO 2014 INSERT INTO cTest VALUES ('Company '+TRANSFORM(m.lnC),m.lnY,100000*RAND(),100000*RAND()) NEXT NEXT BROWSE 1 Get inputs Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.RunXtab() Result is a table with a random name 2 Get inputs and show (browse) the output Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && Inputs oXtab.lBrowseAfter = .T. oXtab.RunXtab() 3 Choose a name for the output table Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && Inputs oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" && table is named xx oXtab.RunXtab() 4 Output into a cursor rather than a table Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && Inputs oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.RunXtab() 5 Show null values (if exists) Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.RunXtab() 6 Close the input table after run Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.RunXtab() 7 Add a supplementary row with total Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 8 Show both nInput and nOutput Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.nMultiDataField = 2 oXtab.acDataField[1] = 'nInput' && cells contains Inputs oXtab.acDataField[2] = 'nOutput' && cells contains Outputs oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 9 Show three columns : nInput, nOutput and nInput - nOutput Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.nMultiDataField = 3 oXtab.acDataField[1] = 'nInput' && cells contains Inputs oXtab.acDataField[2] = 'nOutput' && cells contains Outputs oXtab.anFunctionType[3] = 6 oXtab.acFunctionExp[3] = 'SUM(nInput - nOutput)' oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() * Note the use of SUM()
Demo 2
A table with inputs and outputs from some companies for each month of the each year. Some values are missing RAND(-1) CREATE CURSOR cTest (cName C(10),nYear I,nInput N(10,2),nOutput N(10,2)) FOR lnC=1 TO 5 FOR lnY=2010 TO 2014 INSERT INTO cTest VALUES ('Company '+TRANSFORM(m.lnC),m.lnY,100000*RAND(),100000*RAND()) NEXT NEXT BROWSE 1 Get total / year (inputs) Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 2 Get average / mounth (inputs) Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.nFunctionType = 3 oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 3 Count the mounths with data for each company in every year (inputs) Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.nFunctionType = 2 oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 4 Get worst (minimum) monthly input value from each year / each company Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.nFunctionType = 4 oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 5 Get the best (maximum) monthly input value from each year / each company Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'nYear' && columns are years oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.nFunctionType = 5 oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 6 Get total / semester (inputs) Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'PADL(nYear,4)+[_sem]+iif(nMonth<7,[1],[2])' && columns are semesters oXtab.cDataField = 'nInput' && cells contains Inputs oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 7 Get quarterly average for nInputs - nOutputs Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cRowField = 'cName' && rows are company names oXtab.cColField = 'PADL(nYear , 4) + [_qtr] + PADL(1 + FLOOR((nMonth - 1) / 3) , 1)' && columns are quarters oXtab.nFunctionType = 6 oXtab.cFunctionExp = 'AVG(nInput - nOutput)' oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 8 Get quarterly average for nInputs - nOutputs, but columns are companies, and rows are quarters Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cPageField = 'nYear' && 'pages' are years oXtab.cRowField = '1 + FLOOR((nMonth - 1) / 3)' && rows are quarters oXtab.cColField = 'cName' && columns are company names oXtab.nFunctionType = 6 oXtab.cFunctionExp = 'AVG(nInput - nOutput)' oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 9 Get quarterly average for nInputs - nOutputs, columns are companies, and rows are quarters but only for quarters with results < 0 Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cPageField = 'nYear' && 'pages' are years oXtab.cRowField = '1 + FLOOR((nMonth - 1) / 3)' && rows are quarters oXtab.cColField = 'cName' && columns are company names oXtab.nFunctionType = 6 oXtab.cFunctionExp = 'AVG(nInput - nOutput)' oXtab.cHaving = 'AVG(nInput - nOutput) < 0' && Having oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() 10 Get quarterly average for nInputs - nOutputs, columns are companies, and rows are quarters, for quarters with results < 0 but only for first company Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cPageField = 'nYear' && 'pages' are years oXtab.cRowField = '1 + FLOOR((nMonth - 1) / 3)' && rows are quarters oXtab.cColField = 'cName' && columns are company names oXtab.nFunctionType = 6 oXtab.cFunctionExp = 'AVG(nInput - nOutput)' oXtab.cHaving = 'AVG(nInput - nOutput) < 0' && Having oXtab.cCondition = 'cName==[Company 1]' && Where oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.lDisplayNulls = .F. oXtab.lCloseTable = .F. oXtab.lTotalRows = .T. oXtab.RunXtab() Demo 3 A table with athletes and their training results RAND(-1) CREATE CURSOR cTest (cName C(10),nResult N(8,2)) FOR lnA=1 TO 5 FOR lnR=1 TO 20 IF RAND()>0.2 INSERT INTO cTest VALUES ('Athlete '+TRANSFORM(m.lnA),100*RAND()) ENDIF NEXT NEXT BROWSE 1 Group each athlete's results by tens of seconds Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cPageField = '' oXtab.cRowField = 'cName' && rows are athletes oXtab.nRowField2 = 0 && distribution oXtab.cColField = 'floor(nResult/10)' && columns are tens results oXtab.cDataField = 'nResult' && cells are results oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.RunXtab() 2 Group the results by tens of seconds, regardless whose are Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cPageField = '' && 'pages' are years oXtab.cRowField = '' && rows are irrelevant oXtab.nRowField = 0 && distribution oXtab.cColField = 'floor(nResult/10)' && columns are tens results oXtab.cDataField = 'nResult' && cells are results oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.RunXtab() 3 Group each athlete's results by tens of seconds, In each column, only the fraction is shown Local oXtab oXtab = NewObject("FastXtab", "fastxtab.prg") oXtab.cPageField = '' oXtab.cRowField = 'cName' && rows are athletes oXtab.nRowField2 = 0 && distribution oXtab.cColField = 'floor(nResult/10)' && columns are tens results oXtab.nFunctionType = 6 oXtab.cFunctionExp = 'nResult/10 - floor(nResult/10)' oXtab.lBrowseAfter = .T. oXtab.cOutFile="xx" oXtab.lCursorOnly = .T. oXtab.RunXtab() |
duminică, 1 februarie 2015
Prevent the message "SET REPORTBEHAVIOR is set to 80. Draft mode preview may not show dynamic behavior."
In report designer, the report can be previewed with a right click.
But, the first time, a warning appear :
"SET REPORTBEHAVIOR is set to 80. Draft mode preview may not show dynamic behavior."
To prevent it follow these steps.
First, some preparations :
1) From the command window, execute this command :
DO (_reportbuilder)
Click on "Create copy" and give it a name. For this example, the copy is i:\reportbuilder.dbf
2) From the command window, delete from this copy, the row where hndl_class = 'PreviewFromDesignerHandler'
DELETE FROM (i:\reportbuilder.dbf) WHERE hndl_class = 'PreviewFromDesignerHandler'
(delete the event)
Now all is prepared. Just add this command before MODI REPORT
DO (_REPORTBUILDER) WITH 3, "the_copy_name"
For this example :
DO (_REPORTBUILDER) WITH 3, "i:\reportbuilder.dbf"
MODI REPORT myreport
See
http://www.tek-tips.com/viewthread.cfm?qid=1737532
http://www.atoutfox.com/nntp.asp
But, the first time, a warning appear :
"SET REPORTBEHAVIOR is set to 80. Draft mode preview may not show dynamic behavior."
To prevent it follow these steps.
First, some preparations :
1) From the command window, execute this command :
DO (_reportbuilder)
Click on "Create copy" and give it a name. For this example, the copy is i:\reportbuilder.dbf
2) From the command window, delete from this copy, the row where hndl_class = 'PreviewFromDesignerHandler'
DELETE FROM (i:\reportbuilder.dbf) WHERE hndl_class = 'PreviewFromDesignerHandler'
(delete the event)
Now all is prepared. Just add this command before MODI REPORT
DO (_REPORTBUILDER) WITH 3, "the_copy_name"
For this example :
DO (_REPORTBUILDER) WITH 3, "i:\reportbuilder.dbf"
MODI REPORT myreport
See
http://www.tek-tips.com/viewthread.cfm?qid=1737532
http://www.atoutfox.com/nntp.asp
Abonați-vă la:
Postări (Atom)