Page 1 of 2

How to insert text into a label

Posted: Wed Oct 05, 2022 11:10 am
by CAsba
Hi everyone,
It's me, the embarassing newbie again. I don't seem able to figure out how to write text into a label; size, color, position, all OK, but 'value', that is, the actual text, I can't find how to.

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 11:30 am
by Klaus
Hi CAsba,

well, you already mentioned it and most of the time that is the correct term to use in scripting:

Code: Select all

...
set the label of btn "your_btn_here" to "I'm the label, Sir!"
...
Best

Klaus

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 11:38 am
by CAsba
Sorry, I don't get it. How ? To be clear, I'm not wanting to write script, or code, into the object, I just want to display a word onto the page (onto the card ?) and I thought, probably mistakenly. that I should use a label to display text. I'm obviously missing something that's probably quite basic.

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 11:40 am
by Klaus
Hm, I don't get it, what object do you want to set the label for?
A button? A group?
Or just a text field without borders?
Or even the titlebar of your stack/window?

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 11:42 am
by CAsba
A text field without borders.

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 11:43 am
by Klaus
Well, the just use a text field and remove its borders (showborder = false).

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 11:45 am
by richmond62
A label and a textField are different things.

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 11:52 am
by Cairoo
What Klaus said earlier is for changing the text of a button. For a label field, you would just

Code: Select all

...
put "some text" into field "your_label_here"
...
because in LC, labels are also fields.

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 12:10 pm
by CAsba
Hi,
In 'edit script' I entered
...
put "Sales" into field "Field1"
...
The background color of the field is showing, it has no borders as prescribed, the text color selected is different to the background color, but the word does not appear.
(Btw, I should confess to my complete ignorance inasmuch as I was previously trying to edit the field by typing into it rather than scripting it; that's because I was working with VBA before.)

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 12:15 pm
by Klaus
Hi CAsba,
CAsba wrote:
Wed Oct 05, 2022 12:10 pm
The background color of the field is showing, it has no borders as prescribed, the text color selected is different to the background color, but the word does not appear.
is the field "big" (wide/high) enough to display the complete text?
In 'edit script' I entered
And what script did you actually work on here?
It will not work in the namely fields script!
CAsba wrote:
Wed Oct 05, 2022 12:10 pm
(Btw, I should confess to my complete ignorance inasmuch as I was previously trying to edit the field by typing into it rather than scripting it; that's because I was working with VBA before.)
You can still do this in LC, click the "contents" button (second from left) in the inspector of your field and just start typing!

Best

Klaus

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 12:21 pm
by CAsba
I entered
"...
put "Sales" into field "Field1"
..."

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 12:24 pm
by CAsba
Many thanks, Klaus, the contents button is just what I needed ! Now it's all fine.

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 12:40 pm
by Klaus
CAsba wrote:
Wed Oct 05, 2022 12:21 pm
I entered
"...
put "Sales" into field "Field1"
..."
the big question was: WHERE did you enter this?

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 5:38 pm
by dunbarx
CAsba, and others.

I think the issue here is that a label field itself is a bit special. So though one can "put" a value into a label field, or "set" its text property, one cannot easily edit it.

CAsba, is this the issue? Because if you do not want to change the text of such a field under some sort of script control, even from the message box, then the only way to do so is through the object inspector.

Craig

Re: How to insert text into a label

Posted: Wed Oct 05, 2022 6:04 pm
by Klaus
Will move this thread to the Beginners section.