SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

DESCRIPTION:

ASK WINDOW: TYPEAHEAD gets data from the typeahead buffer. This statement can be used to determine, for example, whether the user has typed [Ctrl/Z] or other special keystrokes. Asking for typeahead data does not lose what is already in the typeahead buffer.

11.15.13 SET WINDOW: TYPEAHEAD

FORMAT:


        SET WINDOW: TYPEAHEAD str_expr 

EXAMPLE:

Example 11-50 SET WINDOW: TYPEAHEAD statement

  set window: typeahead 'FRED' + chr$(13) 
  input 'Name': name$ 
  print name$ 
  end
 
 
Name? FRED 
FRED 

DESCRIPTION:

SET WINDOW: TYPEAHEAD puts data into the typeahead buffer as though the user had typed the data in from the terminal.

11.16 ASK | SET ZONEWIDTH

11.16.1 ASK ZONEWIDTH

FORMAT:


        ASK ZONEWIDTH num_var 

EXAMPLE:

Example 11-51 ASK ZONEWIDTH statement

  ask zonewidth x 
  print 'The current print zone width is'; x 
  end
 
 
The current print zone width is 20 

DESCRIPTION:

ASK ZONEWIDTH finds the print zone width of the device specified and assigns the value to the numeric variable, num_var.

11.16.2 SET ZONEWIDTH

FORMAT:


        SET ZONEWIDTH num_expr 

EXAMPLE:

Example 11-52 SET ZONEWIDTH statement

  print 1,2,3                                           
  set zonewidth 10                                          
  print 1,2,3                                               
  set zonewidth 20 
  end
                                                         
                                                          
1                   2                   3                    
1         2         3                                        

DESCRIPTION:

SET ZONEWIDTH sets the print zone width of the device specified to the number designated. num_expr indicates the width to set the device's print zones.


Chapter 12
SheerPower and DDE

FORMAT:


  SET SYSTEM, SYMBOL '@' + str_expr1: VALUE str_expr2 
  ASK SYSTEM, SYMBOL '@' + str_expr1: VALUE str_expr2 
  
  where str_expr1 is: @program_name, data_for_program 

EXAMPLE:

Example 12-1 SheerPower Control an Excel Spreadsheet via DDE

// Note:  Excel's DDE interface is a bit odd in that 
//        to reference cell B1, we use "R1C2"  (row 1, column 2) 
// This example is also found in \sheerpower\samples folder 
 
dde$ = '@excel,ddetest.xls,' 
 
xlsfile$ = filespec$("sheerpower:samples\ddetest.xls") 
pass url: xlsfile$  // open our spreadsheet 
 
cell$ = 'r1c1' 
data$ = 'Nifty' 
set system, symbol dde$+cell$: value data$ 
 
cell$ = 'r2c1' 
data$ = day$ 
set system, symbol dde$+cell$: value data$ 
 
for x = 1 to 50 
  set system, symbol dde$ + 'r'+str$(x)+'c2': value str$(x) 
next x 
 
ask system, symbol '@': value st$ 
z0 = pos (st$, '0') 
if z0 > 0 then 
  message error: 'Got an error on command# '; z0 
end if 
 
end 

Note

Accessing Excel through SheerPower's DDE interface has only been tested on English versions of Excel.

PURPOSE:

2 or more programs running simultaneously that support DDE can exchange information and commands. For example, SheerPower 4GL can exchange information and commands with Microsoft Word or Excel.

Each application controlled by SheerPower's DDE interface has its own unique way of being controlled. You must be familiar with the application's DDE commands that you want to control with SheerPower. These commands are usually outlined in the application's documentation on DDE.

DESCRIPTION:

The set system, symbol statement sends a command or data to the receiving application.

The ask system, symbol statement asks the application for data to be returned.

The use of the PASS NOWAIT statement is the best way to start an application to control.

The PASS URL statement opens the application if it is not already open. Use the PASS NOWAIT statement to start or open an application that doesn't have a document associated with it.

12.0.1 Checking DDE Syntax

If you receive an error message that reads:


  Bad syntax for execute command 

check to make sure the syntax follows these rules:

For example, the following syntax to make a DDE connection to Quattro spreadsheets is incorrect:


  a$ = "{FileNew}" 
  set system, symbol "@QPW,System": value a$ 
The correct syntax would be:


  a$ = "[FileNew]"  
  set system, symbol "@QPW,System": value a$ 

12.0.2 Accessing Microsoft Word via DDE

Below are some examples of accessing Microsoft Word via DDE using SheerPower:

Example 12-2 Accessing Microsoft Word via DDE

// bookmarks.spsrc 
// written by Mark S. Johnson, CMH 
 
ask system: user user$ 
pass url: "c:\sheerpower\myname.doc" 
delay 1 
// PASS URL statement opens up the Word document 
 
ask system, symbol "@WINWORD,System,Topics": value topics$ 
//Get the available Word topics for the current document 
 
selection$ = piece$(topics$,2,chr$(9)) 
//The name of the current document is the second topic 
 
print "The current Word document is ";selection$ 
 
set system, symbol "@WINWORD," & selection$ & ",user": value user$ 
//Store the user name into the bookmark named "user" 
 
stop 

Example 12-3 More Microsoft Word DDE Commands

//Open a word file whose name in stored in new_word_file$ 
word_command$ = '[FileOpen("' & new_word_file$ & '")]' 
set system, symbol "@WINWORD,System": value word_command$ 
 
//Commands enclosed in brackets [] are Word Basic commands 
 
//Close a Word document whose name is in selection$ 
set system, symbol "@WINWORD," & selection$: value "[FileClose 1]" 
//Close and save the file is set by parameter "1". Using "2" as the 
//parameter closes, but does not save the file. A parameter of "0" prompts 
//the user. 
 
//Exit Word 
set system, symbol "@WINWORD," & selection$: value "[FileExit 2]" 
//Here the parameter "2" says quit and don't save. A parameter of "1" 
//says quit and save. If the parameter is left out or is "0", the user is 
//prompted. 

12.1 Read/Write to the Windows Registry

FORMAT:


  ASK SYSTEM, SYMBOL "\" + REGISTRY_KEY 
  SET SYSTEM, SYMBOL "\" + REGISTRY_KEY 

EXAMPLE:

Example 12-4 Read/Write the Windows Registry

// Fetch the Product ID from the registry 
  rkey$ = '\hkey_local_machine\Software\Microsoft\Windows' + 
                  '\CurrentVersion\ProductId' 
  ask system, symbol rkey$: value kvalue$ 
  print 'Product ID: '; kvalue$ 
  end 
 
 
Product ID: 55555-OEM-1113333-44444 


Previous Next Contents Index