|
- S/ \- P: ~+ v* w
/* Include files */5 a8 a3 w) P0 d5 k
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
' X, S1 R) K- L7 C/ W# include <strstream>- F+ _$ e$ x6 T6 s$ {( S2 c
# include <iostream>$ ^2 r7 Y t( C3 [$ t
using std: strstream;
8 c2 H, \& ~1 D d1 V9 P/ I# D9 ` using std::endl;
) D6 z; R+ f/ ?) E% s$ a using std::ends;( F: V) d) g ?: G: a1 ~- I
using std::cerr;% i# P' m( Z4 g0 J- T: M1 K1 }' _
#else
- @* x2 f: M2 F l' u5 }# include <strstream.h>
" V; @" ]3 e; s8 d8 P# R" ^2 [# include <iostream.h>
, ~& M& I7 V& \4 Y8 a; R7 }#endif
Z4 B+ B' q2 B' Z( s#include <uf.h>; t: c" z# ?$ w
#include <uf_ui.h>
3 n P# s7 j ]. B: Z4 T& D0 h#include <uf_exit.h>
2 O2 w/ C/ H: g: O% Y#include <uf_layer.h>* Q7 \3 q5 u3 c* }2 y% P/ o8 z
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))) f# [& @& O' T) p' z. F
' M( n8 |5 y8 I, S. F% ?static int report_error( char *file, int line, char *call, int irc)
2 b# @/ h1 {# p1 O7 Z' e5 v{' @; U' b8 c0 K* S, X6 S
if (irc)6 x- O" j# C) n o: J
{
4 i# v' K' o9 _ char err[133],
! _; h1 T+ k$ x" w7 g$ O: m4 J msg[133];# S4 W% y4 l0 N. t% u" G4 M8 u ?
( B7 {1 k9 {0 _/ m* i6 G8 T' m sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
2 ^8 j$ F5 y2 C* Z8 W irc, line, file);; M8 Y+ ~* x1 I0 ^
UF_get_fail_message(irc, err);
) L& V+ S# `$ R
" g( M1 y# p- \& A) n2 j UF_print_syslog(msg, FALSE);
0 K: G2 A7 `* x5 D UF_print_syslog(err, FALSE);8 g8 D: I* t! ^ l w1 P8 l
UF_print_syslog("\n", FALSE);
) O2 H4 C9 X9 h( ]; ^" d3 | UF_print_syslog(call, FALSE);. W, y) t! H# f) H0 V
UF_print_syslog(";\n", FALSE);
" H& }$ a% s* T: I: E1 F) [+ D/ r4 w1 U
if (!UF_UI_open_listing_window())+ m3 T: V0 c, |, l2 W/ n+ X
{
# i$ a1 Z# q# b8 u7 t; r UF_UI_write_listing_window(msg);
' o8 f1 F% V5 [1 g" u1 m8 ^# q UF_UI_write_listing_window(err);
$ Z0 z4 O% U* p6 `1 e UF_UI_write_listing_window("\n");
1 y+ o5 i) l X$ G UF_UI_write_listing_window(call);% R# Q: b6 }. ~6 O1 L
UF_UI_write_listing_window(";\n");2 L1 w2 y% e- d3 z
}- m6 I6 y3 g' n/ v
}
& a3 O8 i+ ~1 P# p& Q5 j
5 h0 w6 }1 e8 V return(irc);
) T: M5 h2 C4 z) U9 p# W}
+ Q0 h/ v% @+ v- L) `# W% a4 ^( k0 T9 t+ {; Q
( N3 g5 ^& N6 s+ h/* "File->Execute UG/Open->User Function..." */; U7 N9 ]. F( a2 J# m
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
% ~8 W6 b6 S5 A1 I6 x4 W2 |' T- {{
% p+ S& {; H. G) ?7 s& K /* Initialize the API environment */
. V& {9 |# T0 N9 L4 E) I0 F if( UF_CALL(UF_initialize()) )
: c n5 R5 H$ ~* J {# f2 J1 M0 f4 C# r
/* Failed to initialize */
' I- g$ h' d0 n% f( v' Z return;! l8 M6 `$ K4 u8 h B% ~0 r
}0 ? G- X. @8 X6 j$ S
. p' u9 Z+ d1 W& H /* TODO: Add your application code here */
" U, }& f# G4 F. E4 o f" d0 A5 y5 }# S. Y% P a( y
int layer_number=10;+ M) K Z+ D' o
int layer_status =: |" {7 l( S! s# y9 [$ D) _
// UF_LAYER_WORK_LAYER ;//设置工作图层
" [0 k; @- `" a' G; z2 Y4 P//UF_LAYER_ACTIVE_LAYER ;//设置可选图层
, x4 E* F( X3 x& ~4 L//UF_LAYER_REFERENCE_LAYER ;//设置只见图层) c! o0 ^9 z$ o
UF_LAYER_INACTIVE_LAYER; //设置不可选不可见活动图层7 z+ g7 H! q7 w& F1 }# B' \- I3 G* d
* P6 O' }4 m8 d5 {7 G0 f
UF_LAYER_set_status( layer_number, layer_status);5 i- v' O; k5 H
6 L+ A- N7 P9 _" g /* Terminate the API environment */+ s! Y; U1 w2 o
UF_CALL(UF_terminate());
7 c! X6 d- I( p6 O}
/ ]3 _3 B7 d9 T8 D" v, J9 {/ u4 f2 h& u
/*****************************************************************************
% v, e1 d! P; _/ {* s; s$ E5 X** Utilities
- ]2 H& q( H! z0 j% h+ p*****************************************************************************/: m0 c1 i1 U, O/ j7 i4 U" v" P
# r% Q' Z( s! v. w2 ~7 \extern int ufusr_ask_unload( void )
+ D$ d5 u# {& f& Z{
3 x) x& g2 K, y9 S' \) i return( UF_UNLOAD_IMMEDIATELY );
3 E0 v: ?! T5 V6 ]' y" O; d}4 X6 |2 h& g2 C; g0 ?) `
% j0 `, t1 J$ `9 @& `* m4 G# t |
|