How to find a space in a string?

A forum dedicated to George scripting questions
Post Reply
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

How to find a space in a string?

Post by Lukas »

Hi everyone.
How do I find a space in in a string with George?

Code: Select all

FirstPos(layerName," ")
Always returns "0" even though there are definitely spaces.
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: How to find a space in a string?

Post by Lukas »

It looks like George doesn't handle spaces in strings very well. I stumbled upon this bug report: http://forum.tvpaint.com/viewtopic.php?f=34&t=11792
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
User avatar
NathanOtano
Posts: 1202
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: How to find a space in a string?

Post by NathanOtano »

You can always use the PARSE option that separates each instance between spaces
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: How to find a space in a string?

Post by Lukas »

NathanOtano wrote: 10 Sep 2018, 09:58 You can always use the PARSE option that separates each instance between spaces
Ahh, good idea! I've used that and replaced the spaces with underscores so I can search for the last underscore instead. Thank you!!!

Code: Select all

PARSE LayerName LayerName1 LayerName2 LayerName3 LayerName4 Layername5
IF CMP(Layername5,"")==0
	PRINT "This layername has too many spaces: "LayerName
END
IF CMP(LayerName4,"")==0
	LayerName = LayerName1"_"LayerName2"_"LayerName3"_"LayerName4
ELSE
	IF CMP(LayerName3,"")==0
		LayerName = LayerName1"_"LayerName2"_"LayerName3
	ELSE
		IF CMP(LayerName2,"")==0
			LayerName = LayerName1"_"LayerName2
		END
	END
END
lastUnderscore = LastPos(LayerName,"_")
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
Post Reply