Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Keywords common to PureBasic and TCC

Aug
2,059
83
I thought I would try to create my own Gosub command, via a PureBasic created plugin.

Ref: How to? - Name of current running gosub routine?

Here's the PureBasic code for the Gosub replacement;
Code:
ProcedureDLL.i MyGosub(*lpszString)
  Static theArg.s
  
  theArg = PeekS(*lpszString)
  
  theArg = Trim(theArg)
  
  If Len(theArg) = 0
    Command_("echo USAGE: Gosub label",0)
    ProcedureReturn #Null 
  Else
    Command_("set _gosub=" + theArg,0)
    Command_("Gosub " + theArg,0)
  EndIf     
    
  ProcedureReturn #Null
EndProcedure

This works as it should,
that is,
it creates an internal variable,
_gosub,
to indicate the name of the subroutine.

The problem is,
if I change the name of the procedure to Gosub,
PureBasic will not let me compile the plugin,
as one cannot have a procedure with the same name as a PureBasic keyword.

Gosub is a PureBasic keyword.

Thus,
I am posting this mainly for my future reference,
but other plugin developers using PureBasic may find it of interest also.

Joe
 
The problem is,
if I change the name of the procedure to Gosub,
PureBasic will not let me compile the plugin,
as one cannot have a procedure with the same name as a PureBasic keyword.

Is PureBasic case-sensitive? Perhaps you could call your routine gosub or GOSUB. TCC doesn't care.
 
No, it would appear that PureBasic keywords are not case-sensitive.

Thus gosub = Gosub = GOSUB = GoSub, etc.

Thanks for the idea, though.

Joe
 
If you nest GOSUBs without each having a SETLOCAL/ENDLOCAL pair (or some other mechanism), _GOSUB will be clobbered.
 
Back
Top
[FOX] Ultimate Translator
Translate