Page 1 of 1

[Done] ':' syntax -> Macro Name(Arg): CodeLine

Posted: Sun Jun 25, 2017 7:34 am
by Olliv

Code: Select all

;{
Macro Quote:"
EndMacro
Macro FuncDef(x):Func(UCase(Quote#x#Quote) ) = @x()
EndMacro
Global NewMap Func()
Macro FuncCall(Name, Arg1 =, Arg2 =)
CompilerIf Quote#Arg1#Quote = ""
CallFunctionFast(Func(UCase(Quote#Name#Quote) ) )
CompilerElse
CompilerIf Quote#Arg2#Quote = ""
CallFunctionFast(Func(UCase(Quote#Name#Quote) ),
Arg1)
CompilerElse
CallFunctionFast(Func(UCase(Quote#Name#Quote) ),
Arg1, Arg2)
CompilerEndIf
CompilerEndIf
EndMacro
;}
Procedure Test()
MessageRequester("", "")
EndProcedure
FuncDef(Test)
FuncCall(Test)
Why this first line below is crashing? And...

Code: Select all

Macro FuncDef(x):Func(UCase(Quote#x#Quote) ) = @x()
EndMacro
...and why just this change (replace ':' by carriage return) is okay?

(or is it a native rule I miss?)

(right code below)

Code: Select all

;{
Macro Quote:"
EndMacro
Macro FuncDef(x)
Func(UCase(Quote#x#Quote) ) = @x()
EndMacro
Global NewMap Func()
Macro FuncCall(Name, Arg1 =, Arg2 =)
CompilerIf Quote#Arg1#Quote = ""
CallFunctionFast(Func(UCase(Quote#Name#Quote) ) )
CompilerElse
CompilerIf Quote#Arg2#Quote = ""
CallFunctionFast(Func(UCase(Quote#Name#Quote) ),
Arg1)
CompilerElse
CallFunctionFast(Func(UCase(Quote#Name#Quote) ),
Arg1, Arg2)
CompilerEndIf
CompilerEndIf
EndMacro
;}
Procedure Test()
MessageRequester("", "")
EndProcedure
FuncDef(Test)
FuncCall(Test)

Re: ':' syntax -> Macro Name(Arg): CodeLine

Posted: Sun Jun 25, 2017 11:38 am
by mk-soft
Macros don´t like colon ':'

Code: Select all

;{
Macro Quote
  "
EndMacro
Macro FuncDef(x)
  Func(UCase(Quote#x#Quote) ) = @x()
EndMacro
Global NewMap Func()
Macro FuncCall(Name, Arg1 =, Arg2 =)
  CompilerIf Quote#Arg1#Quote = ""
    CallFunctionFast(Func(UCase(Quote#Name#Quote) ) )
  CompilerElse
    CompilerIf Quote#Arg2#Quote = ""
      CallFunctionFast(Func(UCase(Quote#Name#Quote) ), Arg1)
    CompilerElse
      CallFunctionFast(Func(UCase(Quote#Name#Quote) ), Arg1, Arg2)
    CompilerEndIf
  CompilerEndIf
EndMacro
;}
Procedure Test()
  MessageRequester("", "")
EndProcedure
FuncDef(Test)
FuncCall(Test)

Re: ':' syntax -> Macro Name(Arg): CodeLine

Posted: Sun Jun 25, 2017 2:26 pm
by Olliv
mk-soft wrote:Macros don´t like colon ':'
Thank you for this poetic answer.

There is no detailed rule about what it is supported and what it is not supported.

Also, error message does not tell a macro error, what it causes a little bit of wasted time.

To prevent this for now, I ll exclude this availability of colon in macros.

Thank you again.

Re: ':' syntax -> Macro Name(Arg): CodeLine

Posted: Sun Jun 25, 2017 3:17 pm
by mk-soft
Only at first line

Code: Select all

Macro foo(a,b)
  a = 10 : b = 20
EndMacro
no problem

Re: ':' syntax -> Macro Name(Arg): CodeLine

Posted: Fri Jun 30, 2017 12:56 am
by Olliv
mk-soft wrote:Only at first line
(in the context where macros does not support colon char ':' on the 1st line.)

Thank you for this precision. I observed ':' colon chars were not compiled on the same manner from one pb version to an other one. Old versions had more

Re: ':' syntax -> Macro Name(Arg): CodeLine

Posted: Sat Feb 22, 2025 8:58 pm
by Fred
Already fixed in current release