Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.

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
Anonymous
Not applicable
F. wrote:
1000:
IF NameChar = "a" THEN SubChar = "A"
IF NameChar = "b" THEN SubChar = "B"
IF NameChar = "c" THEN SubChar = "C"
...
is a bit raw. 😉
It's more than raw -- it's ugly, but the only other way I had done capitalization was comparing ascii values. Thanks for showing me the clean way to do it.

Unfortunately, changing that method didn't entirely fix the problem. HOWEVER, the post you sent just before this one WAS they key to my problem. Removing PARAMETERS made the text update properly.

Of course, now I'm confused. Why do I have to use PARAMETERS on my own parameters, but not on Graphisoft's parameters? Or is that just another one of those deep ArchiCAD mysteries?

For those of you keeping track, here is the code after Beister's comments:
IF GLOB_MODPAR_NAME = `pCapitalize` THEN
	NewName = ""
	LowerChars = "abcdefghijklmnopqrstufwxyz"
	UpperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	FOR Idx = 1 TO STRLEN(ROOM_NAME)
		NameChar = STRSUB(ROOM_NAME, Idx, 1)
		CharPos = STRSTR(LowerChars, NameChar)
		IF CharPos THEN
			NewName = NewName + STRSUB(UpperChars, CharPos, 1)
		ELSE
			NewName = NewName + NameChar
		ENDIF
	NEXT Idx
	pCapitalize = 0
	ROOM_NAME = NewName
	PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME
ENDIF
Thanks again!!
Frank Beister
Moderator
I have explained that in different postings hidden in some other deep threads before:

Each instance of an object gets an entry in the database, out of which your project is built. This entry stores position, label etc. AND the starting value of each parameter of the parameter list. If the objects shape is rebuilt, the script has the values refreshed out of this entry. Each var=value inside the script does NOT change this stored values, but the values of the running script, discarded at the end of running. Only PARAMETERS var=value changes the entry but NOT (!!!) the value of the parameter in the running script. If you write

PARAMETERS ROOM_NAME = NewName

the parameter ROOM_NAME has in the next line not the value of NewName, but the value it had before. Only

ROOM_NAME = NewName
PARAMETERS ROOM_NAME = NewName

makes shure both is changed well. The second line can be

PARAMETERS ROOM_NAME = ROOM_NAME

as well. Understandable?
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
Anonymous
Not applicable
F. wrote:
Understandable?
Understood -- but crazy. What possible value could there be in PARAMETERS ROOM_NAME = NewName not actually changing the value of ROOM_NAME? That's not an intiutive idea at all. When would I ever use a line of code like that expecting that nothing will change?
TomWaltz
Participant
Jay wrote:
F. wrote:
Understandable?
Understood -- but crazy. What possible value could there be in PARAMETERS ROOM_NAME = NewName not actually changing the value of ROOM_NAME? That's not an intiutive idea at all. When would I ever use a line of code like that expecting that nothing will change?
I know what Frank is getting at.

Archicad maintains the values in the parameter lists and the values within a script separate. Think of it like this: The Parameter lists controls the value of a parameter at the start of a script. What you do with it after that is up to you.
PARAMETERS ROOM_NAME = NewName
PARAMETERS ROOM_NAME = NAME
is akin to saying:
ROOM_NAME = 1
ROOM_NAME = 2
At no time are you setting the script parameter ROOM_NAME to be NewName.

The line
PARAMETERS ROOM_NAME = NewName
sets the Parameter List variable "Room Name" to be equal to NewName, not the ROOM_NAME variable inside the script.

The line
PARAMETERS ROOM_NAME = ROOM_NAME
overwrites the previous line, setting the Parameter List variable ROOM_NAME back to itself, since the ROOM_NAME variable in the script has not been changed.

Most programming languages have similar concepts (C++, Java, Visual Basic), where variables are edited locally, not globally, and mixing the two can cause a lot of headaches.
Tom Waltz
Anonymous
Not applicable
TomWaltz wrote:
The line
PARAMETERS ROOM_NAME = NewName
sets the Parameter List variable "Room Name" to be equal to NewName, not the ROOM_NAME variable inside the script.
If I have this correct, to make it simple we can say that the only time you should reference any of the parameters in the script is if you are getting a value (MyRoomName = ROOM_NAME), or if you are saving a value into the parameter (PARAMETERS ROOM_NAME = MyNewName). In all other circumstances, you should use variables to perform the manipulations because a statement like ROOM_NAME = MyNewName + "CLASSROOM" is creating a new variable called ROOM_NAME, on the fly.
Frank Beister
Moderator
I do not know, If you have understood, what I was talking about. There are three shedules for the parameters:

1. The parameter list
This list is visible and editable in the object editing dialog window and is stored inside the object. This list is used to preset the values of List #2. The list, which is created by each inserting of the object into the plan.

2. The database list
This list is available, when you are in settings dialog of a placed (or to be placed) object. It gets ONCE its preset values out of list #1. All changes to the parameters in settings dialog and by moveable hotspots will be stored here and finaly in your plan. The list is used to preset the values of list #3.

3. The variable list
Each time a script is started the variable list is cleared. For each parameter of the list #2 will be created a variable by the same (!) name. All changes made inside the script to the variable will be cleared and NOT stored at the end of the script anywhere. Of EACH running of the script. This list has no effect to list #1 or #2. (The scripts run several times, before the shape of the object is done: master-parameter-script, master-userinterface-script, master-2D-script...)

The clue
Inside the script you can change the list #2 and #3. To change the variable list (#3), you just use a variable declaration with, or without LET:

LET ROOM_NAME="living"
or
ROOM_NAME="living"

This changes the variable list and NOT the database list.

To change the database list (#2) you have to use the PARAMETERS command. And it will NOT change the variable list. Just list #2 will get new values.

PARAMETERS ROOM_NAME="living"

or

string="living"
PARAMETERS ROOM_NAME=string
or

ROOM_NAME="living"
PARAMETERS ROOM_NAME=ROOM_NAME

The first and second code example will not change the value of ROOM_NAME in the varaiable list. The last does, because there is a varaible declaration before the PARAMETERS command.

Maybe you had got it yet, but this "model" helps to keep the difference.

P.S. If you are in the editing window/mode the PARAMETERS command changes the parameter list (#1), because there's no database list.

And again, because it was nice to have it: In AC7 you got a raw plan dump, which printed the content of the actual plan into a text file. You was able to see the database list of each placed object. To see the varaiable list you can use the GDL-debugger.
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