Streamline your workflows and master BIM coordination! Program starts April 28!

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Capitalization Routine?

Anonymous
Not applicable
Why doesn't this work? It's making me crazy. GDL is beating me up this week -- I hope it gets better next week.

This is in the Parameter script. Any other suggestions are certainly welcome!

!!ROUTINE FOR CAPITALIZING THE ROOM NAME
IF GLOB_MODPAR_NAME = `pCapitalize` THEN
NameLen = STRLEN(ROOM_NAME)
NewName = ""
SubChar = ""
FOR Idx = 1 TO NameLen - 1
NameChar = STRSUB(ROOM_NAME, Idx, 1)
GOSUB 1000
IF SubChar = "" THEN
NewName = NewName + NameChar
ELSE
NewName = NewName + SubChar
ENDIF
NEXT Idx
pCapitalize = 0
PARAMETERS ROOM_NAME = NewName
PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME
ENDIF

GOTO 2000:

1000:
IF NameChar = "a" THEN SubChar = "A"
IF NameChar = "b" THEN SubChar = "B"
IF NameChar = "c" THEN SubChar = "C"
IF NameChar = "d" THEN SubChar = "D"
IF NameChar = "e" THEN SubChar = "E"
IF NameChar = "f" THEN SubChar = "F"
IF NameChar = "g" THEN SubChar = "G"
IF NameChar = "h" THEN SubChar = "H"
IF NameChar = "i" THEN SubChar = "I"
IF NameChar = "j" THEN SubChar = "J"
IF NameChar = "k" THEN SubChar = "K"
IF NameChar = "l" THEN SubChar = "L"
IF NameChar = "m" THEN SubChar = "M"
IF NameChar = "n" THEN SubChar = "N"
IF NameChar = "o" THEN SubChar = "O"
IF NameChar = "p" THEN SubChar = "P"
IF NameChar = "q" THEN SubChar = "Q"
IF NameChar = "r" THEN SubChar = "R"
IF NameChar = "s" THEN SubChar = "S"
IF NameChar = "t" THEN SubChar = "T"
IF NameChar = "u" THEN SubChar = "U"
IF NameChar = "v" THEN SubChar = "V"
IF NameChar = "w" THEN SubChar = "W"
IF NameChar = "x" THEN SubChar = "X"
IF NameChar = "y" THEN pSubChar = "Y"
IF NameChar = "z" THEN pSubChar = "Z"
RETURN

2000:
!!END
15 REPLIES 15
TomWaltz
Participant
How does it not work? What results do you get from it?
Tom Waltz
Anonymous
Not applicable
TomWaltz wrote:
How does it not work? What results do you get from it?
I start with ROOM_NAME being "Test Name", and after the routine runs, ROOM_NAME is still "Test Name" -- no change at all. It has clearly attempted something because the floor plan preview in the GDL editor blinks when I execute this routine.
Karl Ottenstein
Moderator Emeritus
Jay wrote:
!!ROUTINE FOR CAPITALIZING THE ROOM NAME
IF GLOB_MODPAR_NAME = `pCapitalize` THEN
	NameLen = STRLEN(ROOM_NAME)
	NewName = ""
	SubChar = ""
	FOR Idx = 1 TO NameLen - 1
		NameChar = STRSUB(ROOM_NAME, Idx, 1)
		GOSUB 1000
		IF SubChar = "" THEN
			NewName = NewName + NameChar
		ELSE
			NewName = NewName + SubChar
		ENDIF
	NEXT Idx
	...
ENDIF
Jay,

One thing I see in a quick scan is that SubChar is set to "" outside of the loop, so after it ias assigned once in your 1000 Sub, it will never be "" again ... hence your IF will always be concatenating SubChar... so if you had "ab123c", your routine would produce "ABBBBC".

Rather than move the initialization into the loop, I don't see a need for that variable or the IF block ... just reassign NameChar in your 1000 Sub.

Tip for code on ac-talk ... there is a 'code' button in the format bar when you enter a message - keeps the indentation of the original.

Karl
AC 28 USA and earlier   •   macOS Sequoia 15.4, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable
Karl wrote:
One thing I see in a quick scan is that SubChar is set to "" outside of the loop, so after it ias assigned once in your 1000 Sub, it will never be "" again ... hence your IF will always be concatenating SubChar... so if you had "ab123c", your routine would produce "ABBBBC".
Oops. I originally had it set to "" at the beginning of the 1000 loop, but it still had the same result -- nothing.
Karl wrote:
Tip for code on ac-talk ... there is a 'code' button in the format bar when you enter a message - keeps the indentation of the original.
Thanks! I never noticed that. A wish granted before I even posted it!
Anonymous
Not applicable
Having taken a clue from Karl, I change the routine to this:
IF GLOB_MODPAR_NAME = `pCapitalize` THEN
	NameLen = STRLEN(ROOM_NAME)
	NewName = ""
	FOR Idx = 1 TO NameLen - 1
		NameChar = STRSUB(ROOM_NAME, Idx, 1)
		IF NameChar = "a" THEN NameChar = "A"
		IF NameChar = "b" THEN NameChar = "B"
		IF NameChar = "c" THEN NameChar = "C"
<...>
		IF NameChar = "x" THEN NameChar = "X"
		IF NameChar = "y" THEN NameChar = "Y"
		IF NameChar = "z" THEN NameChar = "Z"
		NewName = NewName + NameChar
	NEXT Idx
	pCapitalize = 0
	PARAMETERS ROOM_NAME = NewName
	PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME
ENDIF
This still doesn't work.
TomWaltz
Participant
Have you tried with without the GLOB_MODPAR_NAME to see if the routine works without the restriction?

OR, did you actually turn on pCapitalize in the Parameters window to trigger GLOB_MODPAR_NAME?
Tom Waltz
Anonymous
Not applicable
TomWaltz wrote:
OR, did you actually turn on pCapitalize in the Parameters window to trigger GLOB_MODPAR_NAME?
Right. pCapitalize is a Boolean parameter. Turning it on triggers the capitalization, at the end of the capitalization the programming switches pCapitalize back to 'off'.
Frank Beister
Moderator
I think you have PARAMETERS once too much. Not:
pCapitalize = 0
   PARAMETERS ROOM_NAME = NewName
   PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME 
but:
pCapitalize = 0
   ROOM_NAME = NewName
   PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME 
Haven't proofed, but this should do it.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Frank Beister
Moderator
1000:
IF NameChar = "a" THEN SubChar = "A"
IF NameChar = "b" THEN SubChar = "B"
IF NameChar = "c" THEN SubChar = "C"
...
is a bit raw. 😉
Try this:
low=ROOM_NAME
result=""
downT=" abcdefghijklmnopqrstufwxyz"
upT=" ABCDEFGHIJKLMNOPQRSTUVWXYZ"
FOR i=1 TO STRLEN(low)
  subT=STRSUB(low,i,1)
  posT=STRSTR(downT,subT)
  IF posT THEN
    result=result+STRSUB(upT,posT,1)
    ELSE
    result=result+subT
    ENDIF
  NEXT i
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm