Salman Khilji wrote:
> I am trying to write a macro that does the following:
> Given the name of a buffer such as GraphView.cpp,
> strip it off the extension and insert in the buffer
> the following string at the current position:
> So I search in the buffer name of a '.' character.
> The problem is that the &sin function always returns
> Here it is
> define-macro function_separator
> set-variable %index &sin $buffer-bname "."
> !if &equal %index 0
> set-variable %classname $buffer-bname
> set-variable %classname &lef $buffer-bname
> insert-string %classname
> insert-string "::"
A couple of mistakes, I think you want this:-
set-variable %index &sin "." $buffer-bname
!if &equal %index 0
set-variable %classname $buffer-bname
set-variable %classname &lef $buffer-bname &sub %index 1
Rather than use %index and %classname which are variables
(slow and expensive) better to use the macro register
variables. So would re-write as follows:-
; #l0 The index into the string.
; #l1 The class name.
set-variable #l0 &sin "." $buffer-bname
!if &equ #l0 0
set-variable #l1 $buffer-bname
set-variable #l1 &lef $buffer-bname &sub #l0 1