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
#52036
F. Beister wrote:
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. ;)
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. :D

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? :wink:

For those of you keeping track, here is the code after Beister's comments:
Code: Select all
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!!
User avatar
By F. Beister
#52064
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?
User avatar
By Jay Rennemeyer
#52075
F. Beister 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?
User avatar
By TomWaltz
#52083
Jay Rennemeyer wrote:
F. Beister 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.
Code: Select all
PARAMETERS ROOM_NAME = NewName
PARAMETERS ROOM_NAME = NAME
is akin to saying:
Code: Select all
ROOM_NAME = 1
ROOM_NAME = 2
At no time are you setting the script parameter ROOM_NAME to be NewName.

The line
Code: Select all
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
Code: Select all
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.
User avatar
By Jay Rennemeyer
#52092
TomWaltz wrote:The line
Code: Select all
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.
User avatar
By F. Beister
#52097
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.