compass1dir.class

来自「是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到」· CLASS 代码 · 共 104 行

CLASS
104
字号
//				compass1dir
//
//  Style for compass directions with directions N, E, S, and W.
//
//  Also allows Top for north, Bottom for south, Left for west, and Right for
//  for east.

*! version 1.0.0  01sep2002
version 8

class {
    class:
    	_nms_for_pi = { "east",  "north", "west", "south", "east",  "center" }
					// so we can be certain of order

} , inherit(codestyle)


// ---------------------------------------------------------------------------
// Returns the angle associated with the direction.
//
// Note, does not matter what "center" returns, nothing would be useful.

program angle
	class exit = (`._nms_for_pi.arrindexof `.stylename''-1) * c(pi) / 2
end


// ---------------------------------------------------------------------------
// Whether the direction is any of the East directions

program iseast
	class exit = index("`.stylename'", "east")
end

// ---------------------------------------------------------------------------
// Whether the direction is any of the West directions

program iswest
	class exit = index("`.stylename'", "west")
end

// ---------------------------------------------------------------------------
// Whether the direction is any of the North directions

program isnorth
	class exit = substr("`.stylename'", 1, 1) == "n"
end

// ---------------------------------------------------------------------------
// Whether the direction is any of the South directions

program issouth
	class exit = substr("`.stylename'", 1, 1) == "s"
end


// ---------------------------------------------------------------------------

program _unabbrev

	local 0 , `0'

	syntax [ , North South East West Center Top Bottom Left Right * ]

	if length(`"`options'"') == 1 {
		local c = substr(`"`options'"', 1, 1)
		local wc 0`:word count `north' `south' `east' `west' `center''
		if "`c'" > "A" & "`c'" < "X" & `wc' == 0 {
			if `"`options'"' == `"N"' {
				class exit "north"
			}
			if `"`options'"' == `"S"' {
				class exit "south"
			}
			if `"`options'"' == `"E"' {
				class exit "east"
			}
			if `"`options'"' == `"W"' {
				class exit "west"
			}

			if `"`options'"' == "T" {
				class exit "north"
			}
			if `"`options'"' == "B" {
				class exit "south"
			}
			if `"`options'"' == "R" {
				class exit "east"
			}
			if `"`options'"' == "L" {
				class exit "west"
			}
		}
	}

	local name `north' `south' `east' `west' `center' `options'

	class exit "`name'"

end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?