|
; `1 b& V/ s$ }- R
/* Include files */2 W, J+ q, r9 g8 H
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
8 I4 i: K$ N0 @# K# include <strstream>! d8 t1 a/ g- x& t/ A
# include <iostream>8 \2 p! {8 L+ B$ m/ t
using std: strstream;
! v- G: I( q3 ^3 U% O using std::endl;
6 q+ o* O4 g, H4 H) [* J8 @% z using std::ends;
# G I+ U- q% J5 y using std::cerr;3 D) T* F: O( R- Q; E, ?3 l( v
#else
& g& `& R4 J' s8 t# include <strstream.h>( c2 Y- E d/ ^+ `: R
# include <iostream.h>
( o* I0 h5 X! b7 F% Q7 h) y#endif5 s. M# h9 i/ [( |+ R
#include <uf.h>$ i1 s) Q' }# k
#include <uf_ui.h>
U5 }& R3 b9 T8 [#include <uf_exit.h>
( _4 W( J" M6 Z- A#include <uf_layer.h>: v' w+ o6 g9 e
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))7 I+ E5 H! ]: N) J; q
4 T$ y/ y. A! i1 S
static int report_error( char *file, int line, char *call, int irc)$ d# _: E' P* }5 g, B, Y& ^! A
{9 r4 f% n4 U8 |9 W5 r0 @8 F
if (irc)
- `' x% `7 ~0 m$ @! a* c+ S {
+ Y/ w. N: `/ b/ P, h" Q' v/ h, e char err[133],
( }0 }; k! Z: ]/ P) d/ N$ J# m msg[133];
4 N8 b% m% p$ u7 R
6 F0 F, c; o4 H8 J! k" p9 h sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",& e7 A; m0 N' z, w# G4 w
irc, line, file);, A4 }6 J% G5 u8 z" e: L" L
UF_get_fail_message(irc, err);
9 b* x8 [0 g" J) g) |5 E' ?$ G2 N
+ l) h1 t) \+ \ @% k, i0 ] UF_print_syslog(msg, FALSE);. N7 l7 C8 U' V7 p: [$ X
UF_print_syslog(err, FALSE);
7 _+ e! n( h' ~ UF_print_syslog("\n", FALSE);# ?9 H$ a8 k- b7 W b# S% B
UF_print_syslog(call, FALSE);
+ M( m( I3 Z* k3 ` UF_print_syslog(";\n", FALSE);3 |0 A8 g* f5 P* U
! k4 V$ H x5 f, r1 b8 G T
if (!UF_UI_open_listing_window()), l, q4 \2 X* h
{
, c7 Q5 S( R1 y! w$ a7 M9 B) n UF_UI_write_listing_window(msg);
" n3 V2 y2 F, D UF_UI_write_listing_window(err);
6 a, h# Y; e2 Z6 L5 }7 k, `) w UF_UI_write_listing_window("\n");$ T8 ~3 N) y0 p' I8 F
UF_UI_write_listing_window(call);
& g4 r( _" R7 M r( b9 |7 H c% j UF_UI_write_listing_window(";\n");
' y, ?0 P, P6 K5 ]" D+ t4 L }- M, n- U7 m% f8 [
}
; m/ I7 ^" R8 A
- g9 r& U5 w5 m6 @2 G+ E# f return(irc);
" } a) u$ I# w. }* f$ u( K3 c8 r}
! s/ H9 S- ]5 w5 A R7 |/ c+ @; [1 n: M$ M9 g
9 {* i2 a$ ]) X- U# I. J8 r- U
/* "File->Execute UG/Open->User Function..." */0 v5 Q" q" R0 y# ?
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )% n1 h8 w+ L) g+ n/ f6 z. Z
{- V6 y O- j+ ]+ T' Z7 Z
/* Initialize the API environment *// q* Z+ ~& l7 k$ o7 d5 n; U1 ?
if( UF_CALL(UF_initialize()) )
8 q" [6 {8 P/ H N- U1 @ {* C v, j2 j4 p# |$ {1 W9 {5 u, V
/* Failed to initialize */4 ?, Y0 n! T% v4 o \' {5 E* }
return;7 x! r2 Z X* m
}" j3 o' m" e9 A" F
* o) a9 o4 ~4 e" O8 p- V /* TODO: Add your application code here */
. V' A9 V% N: Y' V" k7 ]% L, D" Y# _2 W0 z7 n3 |
int layer_number=10;7 e' e: ^1 K& a- `7 x* X4 z
int layer_status =
: B {6 C1 J, f% I( } u" }2 A) P // UF_LAYER_WORK_LAYER ;//设置工作图层
7 s6 f, x* Y4 p' R0 _//UF_LAYER_ACTIVE_LAYER ;//设置可选图层, a/ H/ V- |, t; t7 C( S4 p
//UF_LAYER_REFERENCE_LAYER ;//设置只见图层7 B7 [8 O7 p1 x8 x7 ^* o
UF_LAYER_INACTIVE_LAYER; //设置不可选不可见活动图层: o! G6 ?" ~) _% v& n z/ ]
6 o) a8 M3 g H
UF_LAYER_set_status( layer_number, layer_status);
# E# [" @% ^7 \! J0 G0 p4 f# `6 V, _7 R, S
/* Terminate the API environment */0 z$ O* q& k" F% s; F
UF_CALL(UF_terminate());! |- E3 e' x7 j3 Q' B
}
) @8 s) @0 d# r3 R7 ]7 D) U5 q3 V
! ~. T+ Q# k8 k) K7 a/*****************************************************************************
' |- w/ e8 V, K# g** Utilities( _$ C; K6 t2 G0 V
*****************************************************************************/
+ d7 W' n, R9 _' t, L# \+ D7 K L1 v$ c; y0 a; @, B. n
extern int ufusr_ask_unload( void )
o* Y( h* T& e) C{
2 f+ l# h' l* Z& r; E% n return( UF_UNLOAD_IMMEDIATELY );
0 g+ p5 A4 q/ i- ?3 y$ P}6 ?, S: Z5 }8 l3 n% k% Q
4 Z# q9 w/ L) Z
|
|