Author Topic: Squirrel Documentation: ".Matches"  (Read 2535 times)

Offline BackInTheSandbox

  • Multiple posting newcomer
  • *
  • Posts: 18
Squirrel Documentation: ".Matches"
« on: August 31, 2023, 01:16:10 pm »
Hi,
a long time ago I got some help in this forum:
You probably can use squirrel scripting to do what you want...
Code
[[if(ReplaceMacros(_T("$TARGET_NAME")).Matches(_T("Debug"))){print("MYDEBUG");} else {print("MYRELEASE");}]]

That script worked very well but now I need to change that script. I don't want to check, if the build target is "Debug". I want to check, if the target contains "Debug". Basically I want this:
Code
[[if(ReplaceMacros(_T("$TARGET_NAME")).Contains(_T("Debug"))){print("MYDEBUG");} else {print("MYRELEASE");}]]
This doesn't work, because 'Contains' is not a valid keyword."No problem" I thought, just google the squirrel documentation. But I'm surprised to find that there isn't even 'Matches' mentioned anywhere in the documentation. So I'm at a loss here. Can anyone point me to a documentation about squirrel scripting for Code::Blocks?
https://wiki.codeblocks.org/ gives me a "Service Unavailable".
Thanks in advance,
BackInTheSandbox

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Squirrel Documentation: ".Matches"
« Reply #1 on: August 31, 2023, 01:50:36 pm »
There are bindings in C::B source for many wxString methods, see src\sdk\scripting\bindings\sc_wxtypes.cpp
Code
BindMethod(v, _SC("Matches"), wxString_Matches, _SC("wxString::Matches"));
You can add one binding for Contains() (it should be straightforward) or continue using Matches() with wildcards.

EDIT: You can also use Find().
« Last Edit: August 31, 2023, 01:54:36 pm by Miguel Gimenez »

Offline BackInTheSandbox

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Squirrel Documentation: ".Matches"
« Reply #2 on: August 31, 2023, 03:17:57 pm »
There are bindings in C::B source for many wxString methods, see src\sdk\scripting\bindings\sc_wxtypes.cpp
Code
[...] or continue using Matches() with wildcards.
Thank you very much! Wildcards are sufficient for my task.
Regards,
BackInTheSandbox