Great task for new users of liveCode and for current users this is straightforward.
I thought I'd ask ChatGPT how to do this, to see where it's at with LC.
I asked ChatGPT :
Code: Select all
create livecode script that asks user for their name and then generates a phrase "Hello <name>" in a field
This is its considered response!
Open LiveCode and Create a New Stack: Start by opening LiveCode. In the LiveCode IDE, create a new stack by going to File > New Stack > Default Size. This will be your main working area for the script.
Add a Button to Your Stack: From the Tools palette, select the Button tool and draw a button on your stack. This button will trigger the action of asking the user's name and then greeting them.
Add a Field to Your Stack for Displaying the Greeting:
From the Tools palette, select the Field tool (it might look like a T or an A, depending on your version of LiveCode).
Draw a text field on your stack. This field will be used to display the greeting message.
Name the Field for Easy Reference:
With the field still selected, open the Property Inspector. You can do this by right-clicking on the field and selecting "Property Inspector" or by simply double-clicking on the field.
Go to the General tab and find the Name property. Give your field a meaningful name, like greetingField. This makes it easier to reference in your script.
Code the Button to Ask for the User's Name: Double-click on the button you just created to open the Button Inspector. Go to the Script tab to write your LiveCode script. Enter the following code:
Code: Select all
on mouseUp
ask "What is your name?" with ""
if it is not empty then
put "Hello, " & it into field "greetingField"
else
put "Hello, stranger!" into field "greetingField"
end if
end mouseUp
Not bad - while I have seen errors with LC scripts generated with AI previously, this is definitely improving.
It reads like a clear tutorial, and will probably be a useful too for speeding up learning...