2006-04-08

변수(variables)


set myRace to "Human"

set yourRace to "Klingon" as string

copy "Romulan" to hisRace

set myNumber to 100
get myNumber

set myNumberText to 100 as text

set yourFloat to 3.141592
yourFloat

set myList to {"Human", "Klingon", "Vulcan"}

set myRecord to {race: "Human", age: 30, gender: "male"}

변수를 지정할 때에는 set과 copy를 이용합니다. set과 copy는 똑같은 역할을 하지만 방향이 정반대입니다. 변수가 갖고 있는 값을 꺼낼 때에는 get을 이용합니다. 그렇지만 스크립트편집기에서는 get를 생략한 채 변수 이름만 적을 경우에 결과창에 호출된 변수의 값이 표시됩니다.
AppleScript의 data class(type)는 Java나 PHP에서의 그것과는 좀 다릅니다.


변수의 유형설명
Boolean논리에 의한 참, 거짓
ClassA class identifier
Constant응용프로그램이나 AppleScript에서 지정한 값, 상수
Data원시 데이터. AppleScript에서 표현할 수는 없지만 변수의 값으로서 저장할 수는 있음
Date날짜와 시간
File Specification파일의 이름과 경로. 아직 생성되지 않아 실제로 존재하지 않는 파일의 정보를 가질 수도 있음
Integer정수. 음의 정수, 0, 양의 정수(자연수)로 이루어지고, 소수점이 붙지 않음
International TextCharacter data in the form of international text
List순서를 갖춘 변수의 집합
Number정수, 실수와 같은 용도
Real실수
Record속성의 집합
ReferenceA reference to an object
RGB Color색상을 구성하는 빨간색(red), 녹색(green), 파란색(blue)의 정수값의 집합
String문자열, 문장
Styled Clipboard Text클립보드에 저장된 문자. 스타일과 폰트 정보가 포함됨
Styled Text스타일과 폰트 정보가 포함된 문자
TextString과 같음
Unicode TextCharacter data in the form of Unicode (2-byte) text
Unit Type Value Classes길이, 면적, 체적, 용량, 부피, 기온 등 도량형 단위
AppleScript에서 사용할 수 있는 data의 유형




current date
month of (current date)


set myNumber to 1
set yourNumber to 2
myNumber + yourNumber
-- 3

set myText to " year"
(myNumber as string) & myText
-- 1 year



set theKM to 1 as kilometers
set theMile to theKM as miles
get theMile


set theKG to 100 as kilograms
set thePound to theKG as pounds
get thePound


길이넓이부피용량무게온도
centimetres
centimeters
feet
inches
kilometres
kilometers
metres
meters
miles
yards
square feet
square kilometres
square kilometers
square metres
square meters
square miles
square yards
cubic centimetres
cubic centimeters
cubic feet
cubic inches
cubic metres
cubic meters
cubic yards
gallons
litres
liters
quarts
grams
kilograms
ounces
pounds
degrees Celsius
degrees Fahrenheit
degrees Kelvin
AppleScript에서 제공하는 도량형 단위

0 Comments:

댓글 쓰기

<< Home