The Global Archicad Community

Stay informed. Get help. Share your knowledge.

Everything about using Libraries and Library Parts - Doors/Windows/Objects/Stairs etc. (Example: How can I display a Transom above my Door?)

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, Gordana Radonic, nbalogh, mnguyen, gkmethy, Gergely Feher

User avatar
By Jay Rennemeyer
#51902
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
User avatar
By Jay Rennemeyer
#51908
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.
User avatar
By Karl Ottenstein
#51916
Jay Rennemeyer wrote:
Code: Select all
!!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
User avatar
By Jay Rennemeyer
#51919
Karl Ottenstein 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 Ottenstein 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!
User avatar
By Jay Rennemeyer
#51922
Having taken a clue from Karl, I change the routine to this:
Code: Select all
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.
User avatar
By TomWaltz
#51925
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?
User avatar
By Jay Rennemeyer
#51932
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'.
User avatar
By F. Beister
#52013
I think you have PARAMETERS once too much. Not:
Code: Select all
pCapitalize = 0
   PARAMETERS ROOM_NAME = NewName
   PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME 
but:
Code: Select all
pCapitalize = 0
   ROOM_NAME = NewName
   PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME 
Haven't proofed, but this should do it.
User avatar
By F. Beister
#52014
Code: Select all
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:
Code: Select all
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