|
+ p* N$ n4 N4 i! n3 }! E/* Include files */
- `& O9 Y t; K1 L& B#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )8 s+ u6 o' |9 d* D7 S
# include <strstream>
% i: p9 ?) q" \/ w; l7 L. i# include <iostream>3 ^8 }6 K o, Q1 v/ R ?
using std:strstream;8 V3 d3 L/ Y& C8 j, `& `7 Y
using std::endl; : B' a) k; e2 O6 k
using std::ends;
% o h) m9 y# g t using std::cerr;
0 {. ~5 E2 O/ k1 N5 ?6 c) l; E0 y#else- d% f- X. i- A" t# F
# include <strstream.h>0 S/ u, ?5 y6 h/ W S( R
# include <iostream.h>
. ^8 m7 J W- T% E0 r#endif
# V- F0 p9 z& q5 J1 i7 V1 p5 j#include <uf.h>5 v% }/ j0 n- K/ U" }# {5 D% L' z
#include <uf_ui.h>
+ E& R& q7 ]2 v& ~1 t# ^! l6 f0 d#include <uf_exit.h>6 _: Q# d# c# P9 F! n( V
#include <uf_layer.h>
Y+ u' K: a i0 }. y: y8 h#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))). B8 x- u- O( A6 e+ i; H9 b
0 p/ j: R: O0 A) ]3 ]; ?
static int report_error( char *file, int line, char *call, int irc)7 ]/ p) I2 C# u: r. P6 i
{
# ^. [# ?5 \" S) J if (irc)$ I- x% z4 V6 y# C6 c5 M, S9 s" m
{
" M9 X- L1 g: ]+ w f, I6 j char err[133],7 m$ ?! o( d2 t0 ?) t: k) d
msg[133];% x, K! ^# S! E" L5 i6 n% p" y
6 J- F) z5 [8 e& _9 K sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",. ] D+ {+ F8 l/ n1 K
irc, line, file);
* g9 D$ L7 r, f( u: C+ H1 l. L( ~ UF_get_fail_message(irc, err);
+ O. s' u' q+ I, j5 {5 u+ Q5 {. e$ y' k* b! e
UF_print_syslog(msg, FALSE);
# h5 B) c9 S& _* t& G UF_print_syslog(err, FALSE); ~# F) j3 U. r8 m. C7 Z6 f1 B
UF_print_syslog("\n", FALSE);
2 [& @2 g$ i O3 t H UF_print_syslog(call, FALSE);+ `) u3 o6 N5 B* y# f+ {* q' t
UF_print_syslog(";\n", FALSE);9 n4 w% a: Y4 E3 U% ]" I H
3 G8 Z; N# i' a& P if (!UF_UI_open_listing_window()): \7 N5 H5 r) E7 x4 B. S
{- ~6 N4 i$ ~1 x. i
UF_UI_write_listing_window(msg);
. ]2 h/ f' i2 u. U) O: }1 i7 D5 R, m UF_UI_write_listing_window(err);
- T+ f/ z q: P1 t# j$ v9 D) F UF_UI_write_listing_window("\n");
7 o- V! W( X8 Q4 U/ G UF_UI_write_listing_window(call);: e* j7 R# l3 @, d K& k7 r
UF_UI_write_listing_window(";\n");1 j9 d! i6 S5 w# H
}
. v) v# f6 |" h& M( X }5 [9 c( o2 A1 Q" h( m. c
; d6 q7 A0 `7 C4 E" I return(irc);
% U) ^& r) w/ Z7 Z9 K}. D& I2 g7 r( Z3 L, X3 Q6 K
- k/ ?* k6 x0 r: {. R+ R; T' l4 q0 Z% a
/* "File->Execute UG/Open->User Function..." */
" v5 p( _2 Q: ~7 A5 c1 \1 Hextern DllExport void ufusr( char *parm, int *returnCode, int rlen )' h" E9 t- @# l& v
{5 @' F4 Y2 e3 o$ S% P$ _9 E
/* Initialize the API environment */
( ]1 q9 Y6 L) q8 \/ k& o2 O if( UF_CALL(UF_initialize()) ) 2 |+ K- y2 M" ?" L: R( `
{& m6 Y/ U+ V, @, J. r" i8 b
/* Failed to initialize */
( }5 f; s; U( D$ y1 l1 e3 K$ p return;
' j7 I- q* s5 f- b }
7 ]. R4 m* Z- |) O+ F
0 C0 i% h' W# o. V/ A5 F$ b4 Y/ g /* TODO: Add your application code here */, g- y* i0 I7 n5 E
* r6 J8 K; U& S$ J u5 Y
int layer_number=10;
+ N! F& o0 o3 V8 ?1 [9 W int layer_status =
2 A" R& y& v& G // UF_LAYER_WORK_LAYER ;//设置工作图层
4 e5 d. f" x: [: }/ A# N/ Q//UF_LAYER_ACTIVE_LAYER ;//设置可选图层
4 ^5 C4 N' w. L3 n: H' C# M1 H( R//UF_LAYER_REFERENCE_LAYER ;//设置只见图层6 {; n1 \. x! O& J+ }
UF_LAYER_INACTIVE_LAYER; //设置不可选不可见活动图层
7 T$ I8 I7 ], p( O+ v6 p# a @/ j- z* h- r ~
UF_LAYER_set_status( layer_number, layer_status); e; k* K! |7 m; d# C+ Y4 @5 x5 h
" {( M* |3 M; V' a, o6 L
/* Terminate the API environment */
! c; N1 M) ?9 }4 R* g* ^ UF_CALL(UF_terminate());) X9 K0 F {9 w2 ~
}; _7 F; J& _' \; V& @5 g3 S
3 w2 u5 Y/ ^3 h' t
/*****************************************************************************: b# M5 V& ~+ l% k7 t' O; a7 |
** Utilities1 X6 n% t' ^/ p( O" }& ]) O6 m7 E) F* I- X1 j
*****************************************************************************/5 [1 N* E7 m% v7 Q3 d0 g
' Y$ h+ N0 ~; K1 z
extern int ufusr_ask_unload( void )
/ m7 U7 w; A" k" p1 A8 F% s{ x$ I* L) ]' \* o5 [
return( UF_UNLOAD_IMMEDIATELY );' x% o+ {* O, f
}1 e% c. V4 u. y; y7 K1 A) }& d
6 h K/ l& u- F4 o: T4 Z; W0 W |
|