|
$ k4 l( E0 y! J; R* B/* Include files */8 ?; R% P0 |5 V5 s8 M* Z' c( d8 @
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
0 t' @0 P2 r0 |# y# O3 Z# include <strstream>" a8 K, _4 e+ W% M% W
# include <iostream>9 i. k& g; r. l; C6 l( h2 Q4 f
using std:strstream;
+ E% G' r: v) ? U4 M) y8 T using std::endl; 2 m+ n* Q# S2 Z4 p* R" A0 r
using std::ends;
E6 e# i$ P5 v* i# j using std::cerr;1 w* J& s" ]: }/ g) U2 T8 b
#else4 B5 I7 l2 B: S! g* H2 [
# include <strstream.h>( I5 _/ y; B- N' s4 p4 ^
# include <iostream.h>9 h4 X# ?$ O2 W4 [% {; I7 u
#endif3 S: ~3 E2 \' ?6 v# C6 S G% r
#include <uf.h>1 U; g' t/ `2 ]* F2 s1 }& I
#include <uf_ui.h>0 r) U/ z) K$ p
#include <uf_exit.h>
& A+ ?2 C. o+ n2 l#include <uf_layer.h>5 r& N! ~, F9 W/ `8 K; T2 w
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))). b, X0 q+ G7 S. p0 F2 I( X
/ W: K* k* B2 U
static int report_error( char *file, int line, char *call, int irc)2 A# X9 B3 P! m
{7 v& R# K/ y- S2 K% ?: E' B" [
if (irc)) z" z8 p d+ x5 R9 x0 ]
{
% S. J; M1 W+ K" U& Y char err[133],
* X8 E" g) u* s) H; ~; t* U* Q" o msg[133];6 V" C- w3 F% o+ K, Z3 a
7 K$ b7 d1 _2 ^' R! i sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
/ } x' S' x. |) @4 p$ Y4 k irc, line, file);1 m2 O- _3 a& A; z+ K
UF_get_fail_message(irc, err);
2 ?9 F4 \, c# \" D, ?9 a
& z7 W) I3 Y4 U" l- r UF_print_syslog(msg, FALSE);
) Z1 C8 H& Z/ ]4 U } UF_print_syslog(err, FALSE);
- \" Z( o! u' U$ C8 W+ J UF_print_syslog("\n", FALSE);
) ^# B" Z8 o& C& y UF_print_syslog(call, FALSE);
- Z2 t8 \% \4 S2 z, [3 ] UF_print_syslog(";\n", FALSE);
* {' @1 e. P; g& Y* R+ y! V7 r' _5 G" M5 X
if (!UF_UI_open_listing_window())
. m) g& \( a+ r; @ {% l$ w7 ~1 D' L, C. ?- U% a+ K
UF_UI_write_listing_window(msg);' u+ q" y0 D/ O. i1 ~/ }/ h2 ~
UF_UI_write_listing_window(err);, m: o$ f' @0 x
UF_UI_write_listing_window("\n");4 S: e' t' x) B& Q; w/ C" H
UF_UI_write_listing_window(call);
/ @2 [' A$ h+ ~! H; y3 f UF_UI_write_listing_window(";\n");
6 H4 o1 A$ _) [/ Z }7 \- i8 x( b2 Y5 h+ L& H
}) P3 U! }: Y+ D& U; t' r3 E
" } n$ r8 g/ n4 J return(irc);- W e, H1 D' [
}
. k- e% }$ X3 B2 z5 r0 o" @+ {) g7 j+ e1 A9 }2 S6 B0 J4 D
V' d2 m& g2 m' R c/* "File->Execute UG/Open->User Function..." */
7 \. b+ z8 X- @) ]8 l g% o& ~3 r7 Wextern DllExport void ufusr( char *parm, int *returnCode, int rlen )0 n. F" n# m. V, H, V" Q
{
$ B5 K3 b0 j8 E( P /* Initialize the API environment */
, Y. T" ^6 p7 h0 ]8 D if( UF_CALL(UF_initialize()) )
& h' ~2 I [: W/ L R/ O8 ] {
* z) b: I% Z0 H) j7 |: F* J7 A /* Failed to initialize */
. L8 B# T9 X4 x0 H( p5 V4 z return;
# W# m% P* U8 c }
1 S1 b4 H- m3 u. k [6 S \
! p2 n- y2 f4 y+ x8 `$ f /* TODO: Add your application code here */$ Y$ a. ^. R" z2 n( K# B9 Y; f) y( ^
! ?. g7 N$ \0 l3 D; P
int layer_number=10;
4 i6 g }4 G- Z5 ? R int layer_status =
9 n4 h% D9 e" P$ C3 t( g( l // UF_LAYER_WORK_LAYER ;//设置工作图层
( B% ~( h R4 O1 q1 v0 x: j7 n0 e//UF_LAYER_ACTIVE_LAYER ;//设置可选图层
/ @' |* V! D" r3 R# h//UF_LAYER_REFERENCE_LAYER ;//设置只见图层
8 P# C9 C, Q/ h6 q1 ~9 u' mUF_LAYER_INACTIVE_LAYER; //设置不可选不可见活动图层
" O6 \% `1 O- u8 V' u5 }7 a3 ?5 Y* H- t; d/ {# D2 a. b& w- G
UF_LAYER_set_status( layer_number, layer_status);
. B5 x2 O5 F: H- I3 F$ e9 k% G8 d# @5 W9 B/ n3 I6 X8 V1 k& w
/* Terminate the API environment */% h/ Y8 C) s) r0 e/ f- b! ~& c
UF_CALL(UF_terminate());1 m$ e& O; c j& R
} F: [, j1 x. D7 r% r& @- x8 g. M, j
# {+ w% ]9 R6 ~; u6 o/*****************************************************************************( S/ ]1 F* C: X% m0 F* [" e
** Utilities. d+ e' x$ A; [/ f
*****************************************************************************// j* {2 r: x( Y! C1 ?- F. n
, ~: ~) ?6 ?3 a+ P* T
extern int ufusr_ask_unload( void )% G' L2 `7 T/ i* B
{
0 [) B; m( i0 u+ d* Q3 F5 |8 z% |! M# ^ return( UF_UNLOAD_IMMEDIATELY );
' H, R2 k, O' ]* |" o$ t U}
* a/ d, {- s! a! T. ~: H
; V, x5 n& B9 j* t% D; s2 {; h4 ` |
|