63 lines
1.7 KiB
Plaintext
63 lines
1.7 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: This script registers the command PCMD
|
|
; @Description:
|
|
; The command PCMD executes one line of PRACTICE code with macro substitution
|
|
; PCMD <PRACTICE line>
|
|
; Future version of TRACE32 might have this command build in.
|
|
; @Keywords: practice, macro, substitution, globalon, command
|
|
; @Author: HLG
|
|
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
|
; --------------------------------------------------------------------------------
|
|
; $Id: pcmd.cmm 7373 2014-07-08 10:44:24Z smeister $
|
|
|
|
|
|
LOCAL &cmd
|
|
ENTRY %line &cmd
|
|
|
|
IF "&cmd"==""
|
|
(
|
|
IF VERSION.BUILD()>=12560. // GLOBALON is available since 25.Mar.2008
|
|
(
|
|
LOCAL &ppf
|
|
&ppf=OS.PPF()
|
|
GLOBALON CMD pcmd DO "&ppf"
|
|
)
|
|
ELSE
|
|
(
|
|
PRINT %ERROR "TRACE32 too old. PCMD command won't be available"
|
|
)
|
|
)
|
|
ELSE
|
|
(
|
|
; &&cmd="&cmd" // evaluate macros if not yet done by DO command
|
|
; WHILE (STRing.CHAR("&cmd",0)==0x20)||(STRing.CHAR("&cmd",0)==0x0b) // removes trailing whitespace if not yet done by DO command
|
|
; &cmd=STRing.CUT("&cmd",1)
|
|
|
|
// Strip comments
|
|
LOCAL &i &varcmd &instring
|
|
&varcmd=(STRing.LWR(STRing.MID("&cmd",0,4))=="var.")||(STRing.LWR(STRing.MID("&cmd",0,2))=="v.") // Var-Command ?
|
|
&i=0
|
|
&instring=(1==0)
|
|
WHILE &i<STRing.LEN("&cmd")
|
|
(
|
|
IF STRing.MID("&cmd",&i,1)==""""
|
|
(
|
|
&instring=!&instring
|
|
)
|
|
ELSE IF !&instring
|
|
(
|
|
IF (STRing.MID("&cmd",&i,2)=="//")||(STRing.MID("&cmd",&i,1)==";"&&!(&varcmd)) // start of comment ?
|
|
&cmd=STRing.MID("&cmd",0,&i) // strip comment (will also indirectly terminate the loop)
|
|
)
|
|
&i=&i+1
|
|
)
|
|
|
|
// Execute command
|
|
ON ERROR GOTO
|
|
(
|
|
ENDDO // exit if execution of command failed
|
|
)
|
|
&cmd
|
|
)
|
|
ENDDO
|