Delete the field content

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
SEAL29
Posts: 61
Joined: Fri Oct 02, 2020 3:32 pm

Delete the field content

Post by SEAL29 » Fri Oct 02, 2020 8:52 pm

A tried this command, but nothing happens. What needs to be improved on it?

Code: Select all

put empty into field picture1

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: Delete the field content

Post by kdjanz » Fri Oct 02, 2020 9:15 pm

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...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Delete the field content

Post by dunbarx » Fri Oct 02, 2020 11:16 pm

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

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Delete the field content

Post by Klaus » Sat Oct 03, 2020 8:51 am

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! :-)

SEAL29
Posts: 61
Joined: Fri Oct 02, 2020 3:32 pm

Re: Delete the field content

Post by SEAL29 » 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?

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Delete the field content

Post by Klaus » Sat Oct 03, 2020 2:55 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Delete the field content

Post by dunbarx » Sat Oct 03, 2020 3:04 pm

@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

SEAL29
Posts: 61
Joined: Fri Oct 02, 2020 3:32 pm

Re: Delete the field content

Post by SEAL29 » Sat Oct 03, 2020 3:07 pm

Thank you for this much help and patience.

Thanks @Klaus and @dunbarx

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Delete the field content

Post by dunbarx » Sat Oct 03, 2020 3:08 pm

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”