39)値段表の値段を一律料金アップする

| コメント(0)

表の中の選択部分の値段を取り出し入力した値をプラスします。値段の","のつけかたがベタです。。。

set ANS to display dialog "値段を入力してください。" default answer "1000"
set plusNum to text returned of ANS
set plusNum to my replaceAll(plusNum, "円", "")
set plusNum to my replaceAll(plusNum, ",", "")
set plusNum to plusNum as integer

set OriginalDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {""}

tell application "Adobe InDesign CS2_J"
	tell active document
		tell selection
			set cellCount to count cells
			repeat with N from 1 to cellCount
				set myData to contents of cell N
				set myData to my replaceAll(myData, "円", "")
				set myData to my replaceAll(myData, ",", "")
				set myData to myData as integer
				set myData to myData + plusNum
				set myData to myData as string
				if length of myData = 4 then
					set myData to (character 1 of myData & "," & ¬
						characters 2 thru 4 of myData & "円") as string
				else if length of myData = 5 then
					set myData to (characters 1 thru 2 of myData & "," & ¬
						characters 3 thru 5 of myData & "円") as string
				else if length of myData = 6 then
					set myData to (characters 1 thru 3 of myData & "," & ¬
						characters 4 thru 6 of myData & "円") as string
				end if
				set contents of cell N to myData
			end repeat
		end tell
	end tell
end tell
set AppleScript's text item delimiters to OriginalDelimiters

on replaceAll(motoStr, findStr, repStr)
	set OriginalDelimiters to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {findStr}
	set motoStr to text items of motoStr
	set AppleScript's text item delimiters to {repStr}
	set motoStr to motoStr as string
	set AppleScript's text item delimiters to OriginalDelimiters
	return motoStr
end replaceAll
Comments are nofollow setting

コメントする

エントリー一覧

OpenID対応しています OpenIDについて
Powered by Movable Type 8.0.2
漢字イラストロジック-脳トレ京
FREE ONLINE SUDOKU