Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Labeling a Hard-coded Property

James Murray
Participant
I would like to have a simple label which calls out a specific hard-coded property. Not a general properties label. For example, we have a property under General called Remarks. Seems like this should be the code, but it does not work:
DIM _propertyValues[][]
rrr = REQUEST("Property_Value_Of_Parent", "Remarks", type, dim1, dim2, _propertyValues)
_str = 'blank' ! default
IF rrr > 0 THEN
	_str = _propertyValues[1][1]
ENDIF

TEXT2 0, 0, _str
This gives the default text, showing the request did not work.

What I am I missing?
James Murray
Rill Architects • macOS • OnLand.info
10 REPLIES 10

Barry Kelly
Moderator
I haven't tested this, but you are simply retrieving the value of a property.
So there should be no need to declare a multidimensional array for it - it has one value and that is all you need.

Maybe try this.
rrr = REQUEST("Property_Value_Of_Parent", "Remarks", type, dim1, dim2, _propertyValues)
_str = 'blank' ! default
IF rrr > 0 THEN
	_str = _propertyValues
ENDIF

TEXT2 0, 0, _str

Barry.

One of the forum moderators.
Versions 6.5 to 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

runxel
Mentor
First of all:
Why no autotext label? With a favorite this just works fine.

The longer story:
The "ID" in the request is NOT the name of the property! But instead the GUID.

Two ways:
You need to program the label so that you can choose in the UI which of the properties should be requested.
There is a special new UI command for that.

Or:
You use the text tool, write the property as autotext into it, save that as an object and open it.
Inside you will find a PARAGRPAH with a string written that looks like this:
"<PROPERTY-9E10C048-4861-5A48-B07A-B2E9BE4DBC9C>"
That is the autotext string.
But we need the GUID to have it requested. For this you only keep the part with the random alphanumerics and put it inside curly braces, like this:
"{9E10C048-4861-5A48-B07A-B2E9BE4DBC9C}"

This is the ID you need for the request.
Happy coding!
AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

Podolsky
Newcomer
DIM parentProperties[]
r=REQUEST (‘Properties_Of_Parent’, ‘’, parentProperties)

IF r THEN
propertyID=‘’
FOR i = 4 TO VARDIM1(parentProperties) STEP 4
IF parentProperties = yourPropertyName THEN propertyID = parentProperties[i-3]
NEXT i
propertyValues=‘’
r=REQUEST (‘Property_Value_Of_Parent’, propertyID, type, dim1, dim2, propertyValues)
ENDIF

Podolsky
Newcomer
Happy copy-pasting

James Murray
Participant
Thank you, I thought it might be an GUID-decryption thing.

Symbol labels need properties too
James Murray
Rill Architects • macOS • OnLand.info

runxel
Mentor
James wrote:
Thank you, I thought it might be an GUID-decryption thing.

Symbol labels need properties too
You're welcome, James!
True, as soon there are dynamic symbols involved you have to resort to GDL.

It's a bit sad we have to use this workaround to get to the GUID. I am not aware of a simpler method.
The XML export of a property does not hold its GUID. It seems that this will be created at import time.
So in other news: Be aware when you go to a new file which is not based on your template. The GUID will not be the same, so the GDL label with its hardcoded GUID will stop working.
So in the end it might be easier for maintenance to have a selection with UI_CUSTOM_POPUP_INFIELD somewhere in the label.
AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

Podolsky
Newcomer
runxel wrote:
James wrote:
Thank you, I thought it might be an GUID-decryption thing.

Symbol labels need properties too
You're welcome, James!
True, as soon there are dynamic symbols involved you have to resort to GDL.

It's a bit sad we have to use this workaround to get to the GUID. I am not aware of a simpler method.
The XML export of a property does not hold its GUID. It seems that this will be created at import time.
So in other news: Be aware when you go to a new file which is not based on your template. The GUID will not be the same, so the GDL label with its hardcoded GUID will stop working.
So in the end it might be easier for maintenance to have a selection with UI_CUSTOM_POPUP_INFIELD somewhere in the label.
This is not a problem. The code I published above get property value by name. Just using three steps.

runxel
Mentor
Podolsky wrote:
This is not a problem. The code I published above get property value by name. Just using three steps.
Yes, you are right. This makes the GUID juggling much easier.
The code didn't run at first, but I took a second look and will put the code with the small missing piece here:

myPropToReq = "String of the Property Name"

dim parentProperties[]
r = request("Properties_Of_Parent", "", parentProperties)

if r then
	propertyID = ""
	for i = 4 to vardim1(parentProperties) step 4
		if parentProperties = myPropToReq then
			propertyID = parentProperties[i-3]
		endif
	next i
	propertyValues = ""
	r = request("Property_Value_Of_Parent", propertyID, type, dim1, dim2, propertyValues)
endif

text2 0, 0, propertyValues
AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

Podolsky
Newcomer
runxel wrote:
Podolsky wrote:
This is not a problem. The code I published above get property value by name. Just using three steps.
Yes, you are right. This makes the GUID juggling much easier.
The code didn't run at first, but I took a second look and will put the code with the small missing piece here:

myPropToReq = "String of the Property Name"

dim parentProperties[]
r = request("Properties_Of_Parent", "", parentProperties)

if r then
	propertyID = ""
	for i = 4 to vardim1(parentProperties) step 4
		if parentProperties = myPropToReq then
			propertyID = parentProperties[i-3]
		endif
	next i
	propertyValues = ""
	r = request("Property_Value_Of_Parent", propertyID, type, dim1, dim2, propertyValues)
endif

text2 0, 0, propertyValues
Endif not needed before next i

runxel
Mentor
Podolsky wrote:

Endif not needed before next i

True. As long you like oneliner IFs.
I don't.

But that was not the missing piece anyway 🙂
AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!