|
||
|
|
For most GetData groups, you should get the Count! first. This initializes the specified group list so that subsequent commands can get data, name, or other items from that group. It also allows you to access information about all the items in a list quickly and conveniently in a FORNEXT loop, as shown in the example above. If you don't get the count first, you'll often have errors, or even crash WordPerfect. Below are several examples of using the GetData command:
GetData(vSummaryItems; Summary!; Count!; CurrentDoc!)
Type("Number of summary items: "+vSummaryItems)
HardReturn()
// Make sure you have a document summary before using!
GetData(vFieldtext; Summary!; Data!; CurrentDoc!; 1)
Type("Text from 1st summary field:"+ vFieldtext)
HardReturn()
// Make sure you have a document summary before using!
GetData(vItemTag; Summary!; Tag!; CurrentDoc!; 1)
Type("Tag ID of first summary item: "+vItemTag)
HardReturn()
// Make sure you have a document summary before using!
GetData(vDescNameTxt; SummaryTag!; Data!; CurrentDoc!; 17)
Type("Text of Descriptive Name field:"+vDescNameTxt)
HardReturn()
// Make sure you have a document summary before using!
GetData(vPnum; Printer!; Count!; CurrentDoc!)
Type("Number of printers: "+vPnum)
HardReturn()
GetData(vPrinterName; Printer!; Name!; CurrentDoc!; 1)
Type("Currently-selected printer:"+vPrinterName)
HardReturn()
GetData(vPrinterType; Printer!; Type!; CurrentDoc!; 1)
Type ("Type of currently-selected printer: "+vPrinterType)
HardReturn()
GetData(vAbbrevNum; Abbreviation!; Count!; CurrentDoc!)
Type("Number of abbreviations defined:"+vAbbrevNum)
HardReturn()
GetData(vAbbrevTxt; Abbreviation!; Data!; CurrentDoc!; 1)
Type("Text of the first abbreviation: "+vAbbrevTxt)
HardReturn()
GetData(vTable1; Table!; Count!; CurrentDoc!)
Type ("Number of tables in document: "+vTable1)
HardReturn() // returns an incorrect value
GetData(vTable2; Table!; Name!; CurrentDoc!;1)
Type("Name of current Table: "+vTable2)
HardReturn()
GetData(vTable3; Table!; Type!; CurrentDoc!;1)
Type("In a table or floating cell? : "+vTable3)
HardReturn()
//Table=true, Floating cell should return false, but doesn't
GetData(vTable4; TableNames!; Data!; CurrentDoc!;1)
Type("Table Name Data: "+vTable4)
HardReturn()
//Crashes WP if no names in the table!
//Will return a value such as ROW 1
GetData(vTable5; TableNames!; Name!; CurrentDoc!;2)
Type("Name of the table cell/row/column: "+vTable5)
HardReturn()
//Crashes WP if no names in the table!
GetData(vTable6; TableNames!; Type!; CurrentDoc!;3)
Type("Table Name Type: "+vTable6)
//Crashes WP if no names in the table!
//1=Block, 2=Row, 3=Column, etc.
Notice that for Summary!, Printer!, Table!, and Abbreviation! in the examples above, we must get the Count! first. This initializes the list so that we can get additional information, and also lets us know how many items exist in a particular group. Another thing to keep in mind is that if you attempt to get some information for an item that does not exist (for instance, try to get text from the document summary when no document summary exists), a macro error will occur (and in some cases the computer will crash!). To avoid these errors you can test the Count! of Summary! to make sure it does not equal 0 before attempting to get additional information about a list item. In the case of TableNames!, if no names exist in the current table, or if the cursor is not in a table, WordPerfect will crash altogether. Use care when getting names from a table with GetData. Care must be taken when using many of the GetData groups. For example, if you are trying to get information about a table with the Table! or TableNames! groups, but no table exists in the document when you use, a PerfectScript error will occur when the macro tries to invoke the command. The same is true with when you use Summary! or SummaryTag!, but no document summary exists in the document.
For more information on GetData, see the WordPerfect Macro
Online Help, For information on ordering my book see my web page.
Copyright Notice: The information included in the PerfectScript Journal is protected by US Copyright. The author grants you the right to use the routines in your own macros as needed. You may not sell, distribute, or publish them in any form.If you choose to use the information here, you do so entirely at your own risk. No representations are made regarding the fitness of this information for your particular purpose, or for your ability or inability to use the information. You are advised to make backups of all relevant files before implementing any suggestion or technique.© Copyright 1998 by J. Jeppson. |