Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@ginn_nezz

AppleScript で 簡単カンマ入れ

More than 1 year has passed since last update.

198,000 など、3桁ごとにカンマを入れるのがめんどくさかったので、ごくごく簡単に作ってみました。

set thePrice to 198000 as string

set AppleScript's text item delimiters to ""

set thePrice to every character of thePrice

repeat with i from (count of thePrice) - 3 to 1 by -3
    set item i of thePrice to (item i of thePrice & ",") as string
end repeat

display dialog (thePrice as string)

ハンドラで使用する場合は


display dialog (makeComma(198000 as string))

on makeComma(thePrice)

    set AppleScript's text item delimiters to ""

    set thePrice to every character of thePrice

    repeat with i from (count of thePrice) - 3 to 1 by -3
        set item i of thePrice to (item i of thePrice & ",") as string
    end repeat

    return thePrice as string

end makeComma

現状では整数のみで小数点には対応していませんが、ひとまず。

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ginn_nezz
DTPオペレーターです。 applescript、javascriptを駆使してadobe製品をピコピコ動かしてます。 文字写真流し込み、大量のデータベース処理を主にやってます。 今は objective-c にお熱。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?