← 모든 예제
예제 24
Hook on symbol change
a hook for "a symbol changes": say what the chart was and what it
- 분류
- Host: 터미널의 데이터와 엔진 필요
- 권한
- 없음
- 실행하기 전에
- attached to "Symbol changes" in the Script Hooks window
- 하는 일
- none (it prints; the Script Hooks log shows it)
- 실행 방법
- in TTT, open Script Hooks (palette, or the T0 Editor's View menu),
- 언어
>=0.1.1, <0.2.0- 호스트
>=0.1.5, <0.2.0- 필요한 것
- event >=0.1.0, <0.2.0
소스
// Purpose: a hook for "a symbol changes": say what the chart was and what it // became. The smallest useful hook — it only reads the event. // Category: host // Permissions: none // Preconditions: attached to "Symbol changes" in the Script Hooks window // Side effects: none (it prints; the Script Hooks log shows it) // Run: in TTT, open Script Hooks (palette, or the T0 Editor's View menu), // press "+ Add script" under "Symbol changes", choose this file. Run by // hand it reads a "manual" event and says so. lang ">=0.1.1, <0.2.0"; host "ttt" ">=0.1.5, <0.2.0"; requires "event" ">=0.1.0, <0.2.0"; fn main() { let e = event.current(); if e.kind != "symbol_changed" { print("not a symbol change (this was a " + e.kind + " event); nothing to report"); } else { match e.symbol { Some(s) => print("a chart now shows " + s), None => print("the symbol is not known"), } for line in e.data { print(" " + line); } } }