41
centric features In this presentation… macro capabilities more sophisticated functionality advanced macro features • Inspector • Debugging error trapping printing macros structures and user defined types all features discussed in this session are also available with newlook developer (ND)

Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Embed Size (px)

Citation preview

Page 1: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

centric features

• In this presentation…– macro capabilities

• more sophisticated functionality

– advanced macro features• Inspector• Debugging• error trapping• printing macros• structures and user defined types

– all features discussed in this session are also available with newlook developer (ND)

Page 2: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• inspector

– access to variables, objects and properties– read and modify access– remove variables– value and type information– arrays and collections– watch important values

Page 3: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• inspector

– All window

Page 4: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• inspector

– Auto window

Page 5: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• inspector

– Watch window

Page 6: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• debugging

– control and inspect execution– breakpoints– macro context list– observe execution of code even without errors

Page 7: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• types of problems

– error conditions– invalid input– macro logic errors

Page 8: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• breakpoints

– breakpoints halts the execution of a macro or script and gives you a snapshot of its condition at any moment.

– variables and properties can be inspected to analyze the current state.

– variables and property values can be changed to alter the execution of the macro or script.

Page 9: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• breakpoints allow you to:

– observe the condition of the user interface. – determine which active macros/scripts have been

called. – watch the values of variables, properties, and

objects. – change the values of variables and properties. – view which action the macro or script will run next.

Page 10: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• breakpoints occur when:

– execution reaches a line with a breakpoint– you choose Break from the Run menu– you click the Break button on the toolbar– a break expression defined in the Add Watch dialog

box changes

Page 11: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• debugging toolbar

– debugging mode• turn on or off the debugging features. When debugging

mode is turned off breakpoints do not cause execution to halt.

– start• begin execution from current location and proceed until

next breakpoint is reached.

Page 12: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• debugging toolbar

– break• halt execution at the macros current location.

– end• terminate execution of the current macro/script at its

current location.

Page 13: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• debugging toolbar

– step into• continue execution by executing the next statement

and move into the next macro/script being called.

– step over• continue execution by executing the next statement

and move over the next macro/script being called.

Page 14: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• debugging toolbar

– step to cursor• continues execution of the current macro/script until it

reaches the current cursor position.

– toggle breakpoint• turns on or off the breakpoint at the current cursor

position.

Page 15: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• debugging toolbar

– clear all breakpoints• clears any breakpoints currently set

– show next action• displays the next action to be executed.• the editor will display the action with the cursor located

at the statement.

Page 16: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• debugging toolbar

– add watch• add a variable, object or property to the Watch window

to allow its current value to be seen.

– context list• while in break mode, presents a dialog box that shows

all macros that have been called but not yet run to completion.

Page 17: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• debugging toolbar

Page 18: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• context list

– displays the call stack.– shows all macros that have been called to get to this

execution point.– allows you to easily select the macros calling the

current macro to analyze their program logic.

Page 19: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• error trapping

– handling of error conditions.– actions to set error handlers, raise errors or resume

execution.– error handler is called if an error is encountered in

the macro when running.– default run-time error dialog if no error handler is

set.

Page 20: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• OnError macro action

– used to set or clear the error handler.– error handlers can be nested.– default handling displays run-time error dialog.– error handler should test or copy the Err object

properties before another error could be triggered.

Page 21: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• OnError macro action

– Arguments• label

name of location to execute if a macro error occurs.

blank label disables the error handler.

error handler automatically disabled when macro terminates.

Page 22: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Resume macro action

– used to resume execution of a macro after a run-time error has been handled.

– special value of Next to resume at the statement after the one that triggered the error.

– other values allowed to resume at other points.

Page 23: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Resume macro action

– Arguments• label

name of location to execute if a macro error occurs.

Next value behavior depends upon whether the handler is in the same macro as where the error was triggered.

Page 24: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Raise macro action

– Arguments• Number

error number to be raised.

• Descriptiontext description to be displayed in error dialog.

Page 25: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Raise macro action

– generates a run-time error.– can be called from error handler or from general

macros.

Page 26: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Err object

– used to provide information about a run-time error.– only valid when a error handler is executing.– read-only but Raise can be used to set errors.– property of the App object.

Page 27: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• printing macros

– debugging– education– versioning

– clipboard can also be used to bring macro contents across to another application (such as notepad)

Page 28: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

• printing macros

Open DBConnect (SampleConnection, DBServerDDM, ="Network Address=" & NetworkAddress & ";Network

Port=447;Use Encryption for Data=False;Host CCSID=37;Mode=ReadWrite|ShareDenyNone;Isolation Level=ReadCommitted;Process Binary as Character=True")

DBOpen (SampleRecordset, SampleConnection, /QSYS.LIB/QGPL.LIB/QAFCTUTDBF.FILE/DBFILE1.MBR,

DBUseServer, DBOpenForwardOnly, DBLockReadOnly, DBCmdUnknown)RunMacro (Sample - Database actions.First, , )StopMacro

Close DBClose (SampleRecordset)DBDisconnect (SampleConnection)StopMacro

Advanced Macro Programming

Page 29: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• user defined types

– structures.– database records.– Call, RPCCall and WebCall

Page 30: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• predefined data types

– Byte– Boolean– Integer– Long– Single– Double– String– String *– WString– WString *

Page 31: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Type macro action

– used to describe a user defined data type.– can have one or more elements.– multiple element data types are referred to as

structures.– described using predefined data types.

Page 32: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Type macro action example

Type (MyType, Code as Long, Description as String * 32)

Page 33: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Dim macro action

– declares a variable and allocates storage.– convention is to put Dim actions at the beginning of

the macro.– variable type can be a pre-defined type or a user

defined type.– typically used in conjunction with the Type action

and is not usually required for variable creation within macros.

Page 34: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Dim macro action example

Dim (MyVariable, MyType)

Page 35: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• referencing fields

Type (MyType, Code as Long, Description as String * 32)

Dim (MyVariable, MyType)SetValue (MyVariable.Code, 99)SetValue (MyVariable.Description, "Undefined error!")

Page 36: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• referencing fields

Page 37: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Call example

– Type (WIN32_FIND_DATA, dwFileAttributes as DWORD,ftCreationTimeLow as DWORD, ftCreationTimeHigh as DWORD,ftLastAccessTimeLow as DWORD,ftLastAccessTimeHigh as DWORD,ftLastWriteTimeLow as DWORD,ftLastWriteTimeHigh as DWORD,nFileSizeHigh as DWORD,nFileSizeLow as DWORD,dwReserved0 as DWORD,dwReserved1 as DWORD,cFileName as String * 260,cAlternateFileName as String * 14)

Page 38: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• Call example

– Declare (C:\Winnt\System32\Kernel32.dll, FindFirstFileA, , Long, ByVal lpFileName as String, ByRef lpFindFileData as WIN32_FIND_DATA)

– Dim (FindFileData, WIN32_FIND_DATA)– Call (FindFirstFileA, fldFileName,FindFileData, iResult)

Page 39: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• RPCCall example

– Type (InfoTable2, p1 as String * 10, p2 as String * 1, p3 as String * 1, p4 as Long, p5 as String * 20)

– Type (ChridReceiver, p1 as Long, p2 as Long, p3 as InfoTable2)

– Dim (VarChrid, ChridReceiver)

Page 40: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

Advanced Macro Programming

• RPCCall example

– RPCDeclare (Connection1, QSYS, QWCRSVAL, QuerySystemChar, , Output prmRetVar as ChridReceiver, Input prmRetVarLen as Long, Input prmNumofValues as Long, Input prmValueName as String * 10, InputOutput prmError as String)

– RPCCall (Connection1, QuerySystemChar, VarChrid, 44, 1, "QCHRID", fldError, )

Page 41: Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping

centric 8 Training

Workshop 1