Copyright 1984 by ABComputing ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º The 1-2-3 Advantage º º º º by º º º º Jerrold Benedict º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Introduction ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Lotus Development Corporation's 1-2-3, the integrated spreadsheet,database and graphing program, has received high praise from reviewers and the marketplace. While much has been written about its capabilities, little has been documented on one of its most powerful features, its programmability. 1-2-3 can be programmed to automatically load or store files, calculate formulas, print or graph data, or prompt for user input. 1-2-3 commands, or combinations of 1-2-3 commands, can be used to simulate many commands available in Microsoft Basic, or other high-level programming languages. These stored command sequences, or keystrokes, are called keyboard macros. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Executing Keyboard Macros ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ After being stored, 1-2-3 macros are invoked in either of two ways. They are started automatically when loaded with a /FILE retrieve operation, or, if already on the workspace, are started by pressing the Alt key and the letter name of the macro. Macros are named using the /RANGE name create operation, and must begin with a backward slash (symbolizing the Alt key ), followed by a zero or an alphabetic character. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Legal Names of Macros ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ Automatic Macros ³ Alt Macros ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ \0 ³ \A to \Z ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Where Are Macros Put? ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Macros can be put anywhere on the 1-2-3 workspace, provided they do not interfere with area occupied by spreadsheet or database models. Because the 1-2-3 workspace is so large (2048 rows by 256 columns), there is a large area for macro programs. If memory constraints are a problem, macros can be used to load other macros, to erase portions of the workspace, or to load other models. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Storing Macro Keystrokes ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Storing macro keystrokes is a simple task. The command sequences ( or keystrokes ) are first entered in the 1-2-3 workspace in label form ( e.g. preceded by a label prefix). They are then assigned a macro range name following the rules described above. Macros used with other models can be stored in a file and retrieved later. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Sample Macro Keystrokes ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Macro keystrokes can consist of any 1-2-3 command and function available with normal keystrokes, as well as special programming commands. This wide variety of keystrokes provides for a versatile programming language. Many of the 1-2-3 macro keystrokes can be used to accomplish the same tasks as Microsoft BASIC commands and functions, while other are unique to 1-2-3. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ BASIC Commands & Functions ³ ³ Equivalent 1-2-3 Macro ³ ³ ³ ³ Keystrokes ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Program Control ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ IF-THEN-ELSE /XIFORMULA~ GOTO /XGLOCATION~ GOSUB /XCLOCATION~ RETURN /XR INPUT {?}~ " /XNMESSAGE~LOCATION~ " /XLMESSAGE~LOCATION~ " /XNLOCATION~ ON N GOTO /XI(N)~/XGLOCATION~ ON N GOSUB /XI(N)~/XCLOCATION~ END /XQ~ SYSTEM /QY~ RUN {ALT}MACRO NAME (A-Z) ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ File Control ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ LOAD /FR CHAIN /FC~ SAVE /FS KILL /FE~ FILES /FL~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Output Control ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ TAB {RIGHT} PRINT LABEL~ " NUMBER~ LPRINT LABEL~/PP~RANGE~GQ " NUMBER~/PP~RANGE~GQ LOCATE {GOTO} CLS {HOME}/REA1.H20~ USING /RFFORMAT~ " /WCCOLUMN WIDTH~ BEEP {NAME}~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Program Editing ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ TRON, TROFF {ALT}{HELP} EDIT {GOTO}LOCATION~{EDIT} DELETE /REMACRO RANGE~ LIST {GOTO}MACRO LOCATION~ LLIST /PP~MACRO RANGE~GQ NEW /WEY~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Program Documentation ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ REM LABEL~ (NEXT COLUMN) ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Variables ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ LET /RNCVARIABLE~LOCATION~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Text/numeric Conversion ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ VAL {EDIT}{HOME}{DEL}~ STR$ {EDIT}{HOME}'~ Some BASIC commands and functions can only be implemented in 1-2-3 with tricky macro keystroke sequences: ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ FOR-NEXT LOOP ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ FOR-NEXT COLUMN ³ Total no. of loops: 5 ³ ³ (FOR I = 1 TO 5) ³ Current loop no.: 1 ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ³ ³ 1 - Start macro with cursor here ³ ³ 2 ³ ³ 3 ³ ³ 4 ³ ³ 5 ³ ³ ³ ³ /WGRM Recalculate manually ³ ³ /RNCNUMBER~LOCATION1~ Total no. of loops ³ ³ /RNCCOUNTER~LOCATION2~ Current loop number ³ ³ /RNCCOLUMN~ FOR-NEXT column ³ ³ {BS}.{END}{DOWN}~ " " ³ ³ {GOTO}NUMBER~ Calculate total loops ³ ³ @COUNT(COLUMN){CALC}~ " " ³ ³ {DOWN}+(COUNTER)+1~ Calculate current loop ³ ³ {GOTO}COLUMN Start FOR-NEXT loop ³ ³ {EDIT}{CALC}{DOWN}{CALC} Assign RANGE NAME "loop" ³ ³ {PGDN}{PGDN}THIS WORKS!~ Steps between loops ³ ³ {PGUP}{PGUP} " " ³ ³ /XI(COUNTER)<=(NUMBER)~/XGLOOP~ Loop or End MAcro ³ ³ /WGRA Recalculate automatically ³ ³ {GOTO}COLUMN~/XQ~ Return to column, quit ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ 1-2-3 also has commands and functions not easily implemented in BASIC. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Sample Macros ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The following simple macros demonstrate the flexibility and power of 1-2-3 keystrokes. These macros can be combined with other customized macros to form a library of subroutines. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 1. ³ Convert formula to number ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ {EDIT}{CALC} ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 2. ³ Insert one row or column ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ROW COLUMN --- ------ /WIR~ /WIC~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 3. ³ Center labels in row or column ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ROW COLUMN --- ------ /RLC.{END}{RIGHT}~ /RLC.{END}{DOWN}~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 4. ³ Display worksheet formulas ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ /WGFT~/WGC30~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 5. ³ Enter months as column headings across row ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ^JAN{RIGHT}^FEB{RIGHT}^MAR{RIGHT}^APR{RIGHT} ^MAY{RIGHT}^JUN{RIGHT}^JUL{RIGHT}^AUG{RIGHT} ^SEP{RIGHT}^OCT{RIGHT}^NOV{RIGHT}^DEC{RIGHT} {END}{LEFT} ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 6. ³ Save, print or graph worksheet ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ /XMLOCATION~ SAVE PRINT GRAPH FILE:CHART1 ENTIRE W/S BAR GRAPH /FSCHART1~R~ /PPCA /GRG RA1.H100~ TB OML10~ XC13.C22~ MR140~ AF13.F22~ QGQ OSYFC0~Q TFSALES~ QVQ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 7. ³ Calculate year-to-date values ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ CURRENT YTD ENTER CURRENT PERIOD AMOUNT, THEN 100 468 GOTO YTD CELL - INVOKE MACRO 345 590 {EDIT}+{DOWN}{LEFT}{UP}~ - ASSIGN \Y HERE {EDIT}{CALC}~{DOWN} /RNCYTD~{LEFT}~ /XI(@COUNT(YTD)=1)~/RNDYTD~/XG\Y~ /RNDYTD~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 8. ³ Enter numbers using numeric keypad ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ /XMLOCATION~ DOWN RIGHT SELECT SELECT INPUT DIRECTION {?}~ {?}~ - ASSIGN \D, \R {DOWN} {RIGHT} /XG\D~ /XG\R~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 9. ³ If current cell=0, branch to other macro, else quit ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ /RNCHERE~~ /XIHERE=0~/RNDHERE~/XG\A~ /RNDHERE~/XQ~ OTHER MACRO - ASSIGN \A HERE ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 10. ³ Display various named and save graphs in succession ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ /GNU{?}~ - ASSIGN \G HERE Q/XG\G~ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ File Name: ÛÛ 1-2-3.txt ÛÛ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ t to scre