Hi Everyone,
Lets start with some intro of apple script.
Open your apple script editor and enter the text below.
[code]
display dialog "Hello, coding-scripting!"
[/code]
compile and run, a display box will appear with text "Hello, user".
Now to listen to your name, you need to enter below code
[code]
Say "Hello, coding-scripting!"
[/code]
Cool, isnt it.
Now to repeat any command (looping), you have to use repeat command, use the below code, to display the dialog box twice.
[code]
repeat 2 times
display dialog "Hello, coding-scripting!"
end repeat
[/code]
To produce a beep, you need to use beep command.
[code]
beep
[/code]
To beep multiple times, just enter the number (the time you want to produce beep)
[code]
beep 5
[/code]
To set a variable, you need to use set command.
[code]
set myName to "coding-scripting!"
display dialog myName
[/code]
Okay, now how to concatenate the text, we need to use & operator
[code]
set myName to "coding-scripting!"
display dialog "Hello, " & myName
[/code]
Displaying a text box, to grab input from user.
[code]
set myName to the text returned of (display dialog "Enter your name." default answer "" buttons {"Enter"})
display dialog "Hello, " & myName & ". Welcome to coding-scripting!"
[/code]
Mathematical operations for variables :
[code]
set number1 to 5
set number2 to 5
set number3 to number1 + number2
display dialog number3
display dialog "Thanks for reading my tutorial."
[/code]
Creating loop and displaying multiple messages :
[code]
set myMessage to {"Hello user!", "Welcome to coding-scripting!"}
set x to 1
repeat 2 times
display dialog (item x of myMessage)
set x to (x + 1)
end repeat
[/code]
While and if else structure
[code]
set a to true
set b to 0
repeat while x
if a > 5 then
set b to false
else
set b to b + 1
end if
end repeat
[/code]
Thanks for reading my tutorial.
Lets start with some intro of apple script.
Open your apple script editor and enter the text below.
[code]
display dialog "Hello, coding-scripting!"
[/code]
compile and run, a display box will appear with text "Hello, user".
Now to listen to your name, you need to enter below code
[code]
Say "Hello, coding-scripting!"
[/code]
Cool, isnt it.
Now to repeat any command (looping), you have to use repeat command, use the below code, to display the dialog box twice.
[code]
repeat 2 times
display dialog "Hello, coding-scripting!"
end repeat
[/code]
To produce a beep, you need to use beep command.
[code]
beep
[/code]
To beep multiple times, just enter the number (the time you want to produce beep)
[code]
beep 5
[/code]
To set a variable, you need to use set command.
[code]
set myName to "coding-scripting!"
display dialog myName
[/code]
Okay, now how to concatenate the text, we need to use & operator
[code]
set myName to "coding-scripting!"
display dialog "Hello, " & myName
[/code]
Displaying a text box, to grab input from user.
[code]
set myName to the text returned of (display dialog "Enter your name." default answer "" buttons {"Enter"})
display dialog "Hello, " & myName & ". Welcome to coding-scripting!"
[/code]
Mathematical operations for variables :
[code]
set number1 to 5
set number2 to 5
set number3 to number1 + number2
display dialog number3
display dialog "Thanks for reading my tutorial."
[/code]
Creating loop and displaying multiple messages :
[code]
set myMessage to {"Hello user!", "Welcome to coding-scripting!"}
set x to 1
repeat 2 times
display dialog (item x of myMessage)
set x to (x + 1)
end repeat
[/code]
While and if else structure
[code]
set a to true
set b to 0
repeat while x
if a > 5 then
set b to false
else
set b to b + 1
end if
end repeat
[/code]
Thanks for reading my tutorial.
No comments:
Post a Comment