Help us understand the problem. What is going on with this article?

AppleScript で 簡単カンマ入れ

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

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

ginn_nezz
DTPオペレーターです。 applescript、javascriptを駆使してadobe製品をピコピコ動かしてます。 文字写真流し込み、大量のデータベース処理を主にやってます。 今は objective-c にお熱。
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした