Page 1 of 1

Delete the field content

Posted: Fri Oct 02, 2020 8:52 pm
by SEAL29
A tried this command, but nothing happens. What needs to be improved on it?

Code: Select all

put empty into field picture1

Re: Delete the field content

Posted: Fri Oct 02, 2020 9:15 pm
by kdjanz

Code: Select all

put empty into field "picture1"
if that is the correct name for the field it should work to empty the text contents of the field.

If you have set the imageSource property of the field (like it appears you were doing on another thread), you need to empty THAT to get rid of the picture...

Re: Delete the field content

Posted: Fri Oct 02, 2020 11:16 pm
by dunbarx
Hi.

If your field was NAMED "picture1", then it should have emptied without issue.

LiveCode is very forgiving with loose syntax, in that it will allow an unquoted control name, simply because if it is not directed "properly", it will look around to see if anything seems to fit the bill.

Whether that is good practice or not is another issue. It is not. Always quote control names. Always make sure literals are quoted; LC will indeed throw an error if you do not.

But if you had a problem with your line of code then the field was not so named. It cannot be "the first field with a picture in it", if you see what I mean. LC cannot read your mind. You must tell it exactly what you want it to do.

You are working and playing in the LC arena just fine. Keep at it. Keep asking here.

Craig

Re: Delete the field content

Posted: Sat Oct 03, 2020 8:51 am
by Klaus
dunbarx wrote:
Fri Oct 02, 2020 11:16 pm
LiveCode is very forgiving with loose syntax...
True, but after 21 years of using LC and its ancestors I can confirm that the engine is LESS forgiving with every new version.
So better stick to the "official" syntax or it will bite you one day! :-)

Re: Delete the field content

Posted: Sat Oct 03, 2020 2:46 pm
by SEAL29
Hi.
This command work with text in field and deletes it. But not working with image in the field, do I need to add another command?

Re: Delete the field content

Posted: Sat Oct 03, 2020 2:55 pm
by Klaus
Hi SEAL29,
SEAL29 wrote:
Sat Oct 03, 2020 2:46 pm
Hi.
This command work with text in field and deletes it. But not working with image in the field, do I need to add another command?
do you really have an image in a FIELD?
Or did you use my example script and have an imported IMAGE you want to "empty"?
In that case you can:
1. either "empty" the image object:

Code: Select all

...
set the text of img "your image here" to EMPTY
...
2. or delete the complete image:
(Keep in mind that "import paint from file xyz" will always create a new image!)

Code: Select all

...
delete img "your image here"
...
Best

Klaus

Re: Delete the field content

Posted: Sat Oct 03, 2020 3:04 pm
by dunbarx
@Klaus.
True, but after 21 years of using LC and its ancestors I can confirm that the engine is LESS forgiving with every new version.
So better stick to the "official" syntax or it will bite you one day
Hah, I have 33 years.

But I agree about LC becoming less and less forgiving.

@SEAL29. Always quote the things that should be quoted. Always. The good news is that the issues you are having are small structural ones. This does not mean that they will not stop you cold, but it does mean that you are moving forward. Slowly now, but soon much faster.

Craig

Re: Delete the field content

Posted: Sat Oct 03, 2020 3:07 pm
by SEAL29
Thank you for this much help and patience.

Thanks @Klaus and @dunbarx

Re: Delete the field content

Posted: Sat Oct 03, 2020 3:08 pm
by dunbarx
SEAL29.
This command work with text in field and deletes it. But not working with image in the field, do I need to add another command?
You have to know that an image is another control entirely. The text of a field is a property of that field. So you can empty the contents of a field with a command. But you must then delete the image explicitly as well. Two different things.

I still am not clear what the relationship is between your field and the images you want to import. Why is a field the centerpiece of this process? You do not need it at all, you know.

Craig