星期三, 一月 12, 2011
ECL 10.7.1 如何才能正确打印出汉字
foo.lsp文件内容
;foo.lsp
(ext::stream-external-format-set *standard-input* :CP936)
(ext::stream-external-format-set *standard-output* :CP936)
(print (length "好吧"))
(print "TEST" *standard-output*)
(princ "好吧" *standard-output*)
(format t "~%汉字来也")
这个代码只能在文件中执行,如果在ecl console里逐行敲入这些代码,反而出现错误:
ECL (Embeddable Common-Lisp) 10.7.1
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.
Top level in: #<process TOP-LEVEL>.
> (ext::stream-external-format-set *standard-input* :CP936)
> (ext::stream-external-format-set *standard-output* :CP936)
> (format t "汉字来也")
鹤酪
NIL
> (format t "汉字来也")
鹤酪
NIL
>
星期四, 一月 06, 2011
LISP在package如何访问TOPLEVEL定义的全局变量(Global Variable)?
如果在一个main.lisp中分别(load "*....lisp"),载入定义的package或者一些全局的数据.
往往会出现如下场景类似的问题:
CL-USER> (defvar foo 108) FOO CL-USER> foo 108 CL-USER>
CL-USER> (in-package :asdf) #<PACKAGE "ASDF"> ASDF>
The variable FOO is unbound. [Condition of type UNBOUND-VARIABLE]
避免这个情况,就是用如下引用方式:
ASDF> cl-user::foo 108 ASDF>
星期三, 十二月 29, 2010
ECL 10.4.1 在window 用 mingw 3.4.5 编译
first download gc 7.2
http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.2alpha4.tar.gz
展开。
然后进入msys
cd d:/gc-7.2alpha4
敲入命令:
1.首先配置
./configure --enable-shared=no --enable-static=yes --enable-cplusplus --enable-large-config --enable-parallel-mark --enable-threads=win32;make
2.开始编译
make
3.安装到/usr/local目录下,实际的msys local目录下
success then.
cd d:/ecl-10.4.1
//./configure --prefix=/usr/local --enable-boehm=system --enable-longdouble --enable-gengc --enable-precisegc --enable-threads --enable-unicode CPPFLAGS=-ID:\\gc-7.2alpha4\\include LDFLAGS=-LD:\\gc-7.2alpha4\\.libsmake clean;./configure --prefix=/usr/local --enable-threads -enable-boehm --enable-unicode ;make
MSVC:
nmake ECL_UNICODE=1 ECL_DEBUG=0
#include <ecl/ecl.h>
# include <unistd.h>
# include <pthread.h>
int main(int argc, char **argv) {
cl_boot(argc, argv);
cl_object obj=c_string_to_object("\"Hello world\"");
cl_pprint(1,obj);
cl_shutdown();
}
(ext::stream-external-format-set *standard-input* :utf-8)
(ext::stream-external-format-set *standard-output* :utf-8)
--build=pentium4-pc-mingw32如何使用ecl.dll
使用
ecl-config --cflags 及 ecl-config --ldflags 得到你需要传递给你的编译器的变量
发布使用ecl.dll的程序。
必须包含ecl.dll 和ucd.dat 两个文件同执行文件在同一个目录下
ucd.dat
显示汉字:
cl_object obj=c_string_to_object("\"Hello world你好\"");
wxMessageBox(wxString(ecl_base_string_pointer_safe(obj),wxConvUTF8));
ECL生成独立的可执行文件.
1.新建hello.lisp文件,包含如下代码
(princ "Hello world!")
(terpri)
(quit)
2.生成object文件
(compile-file "hello.lisp" :system-p t)
3.link成可执行文件
(c:build-program "hello" :lisp-files '("hello.o"))
4../hello.exe
星期四, 十二月 23, 2010
如何用一个字符串作为Lisp Hashtable的key?
(setq table (make-hash-table)) => #<HASH-TABLE EQL 0/120 46142754>
(setf (gethash "one" table) 1) => 1
(gethash "one" table) => NIL, false
(setq table (make-hash-table :test 'equal)) => #<HASH-TABLE EQUAL 0/139 46145547>
(setf (gethash "one" table) 1) => 1
(gethash "one" table) => 1, T
(make-hash-table :rehash-size 1.5 :rehash-threshold 0.7)
Lisp 如何得到函数返回的多个值?
比如parse-integer 返回2个值。
如果想的到第二个返回值,可以用(nth-value (parse-integer "20") 1)
得到2,字符串索引。
还有其他函数可以得到所有返回值。
nth-value [already mentioned and only pertaining to multiple-vals]
multiple-value-bind [no such thing as multiple-value-let]
multiple-value-call
multiple-value-setq
(multiple-value-list (floor 5 2))
得到:(2 1)
星期一, 十二月 20, 2010
Lisp打开跟踪,输出到log文件
(dribble) ;关闭跟踪输出。
星期二, 十二月 14, 2010
健身一次负重的重量如何计算?(比如哑铃,杠铃)
Repetition Maximum
有两个公式可以计算得出1RM的重量:
Brzycki's 公式
- 重量÷ ( 1.0278 - ( 0.0278 × 重复次数 ) )
另外一个系数的公式
- 重量 × ( 1 + ( 0.033 × 重复次数 ) )
这样一个体重80公斤的人计划一组重复锻炼动作16次计算得出的1RM是:
Brzycki结果:137公斤
另外:122公斤
然后利用另外一张 负重和重复 关系表。
14 to 20RM = 60% of 1RM
11 to 14RM = 70% of 1RM
6 to 11RM = 80% of 1RM
3 to 6RM = 90% of 1RM
得到重复16次相当于60%的 1RM 及137 × 0.6 =82.2 公斤或122* 0.6 = 73.2 公斤
这样就得出每次重复需要举起的实际总量为:82.2/16=5.1375公斤 或73.2/16=4.575公斤
所以锻炼的次数越多,每次需要举起的重量越少。
如果你是哑铃锻炼的话,一个体重80KG的人需要准备一个单只 2.5KG的哑铃或杠铃来举重。
| % 重量 | 重复次数 | % 重量 | 重复次数 | % 重量 | 重复次数 |
| 60 | 17 | 75 | 10 | 90 | 5 |
| 65 | 14 | 80 | 8 | 95 | 3 |
| 70 | 12 | 85 | 6 | 100 | 1 |
实际锻炼中往往根据自己的目的来调整实际重复的次数或RM,这个同锻炼的目的有关系。
下面的表是肌肉锻炼目的和RM的关系,可以自己选择,然后确定实际的重量
1RM的到3RM - 最大刺激神经肌肉力量
4RM以6RM - 最大强度的刺激肌肉肥大
6RM到12RM - 肌肉(肥大)力量锻炼合适
12RM到20RM - 肌肉体积良好和获得良好的耐力
一个比较好的LISP IDE 工具 lispIDE
这个同居可以同SBCL Download - Steel Bank Common Lisp 配合一起使用
如图:
星期五, 十二月 10, 2010
动态扩展的数组
(defvar foo (make-array 1 :fill-pointer 0))
(vector-push-extend (vector 1 2 3) foo)
(vector-push-extend (vector 1 2 3) foo)
星期三, 十一月 24, 2010
如何遍历一个LIST 数组。
简单代码如下,构造一个List数组,然后遍历之。
(defvar alls)
(setf alls (vector '(10 12 14 20 22 26) '(03 05 06 07 11 12)))
(loop for i from 1 to (array-total-size alls)
do(loop for h from 1 to (list-length (svref alls (1- i)))
do(format t "~d," (nth (1- h) (svref alls (1- i))))
)
(format t "~%")
)
星期四, 十一月 11, 2010
MYSQL text column insert into UTF-8 .
http://dev.mysql.com/doc/refman/5.0/en/blob.html
text is nonbinary strings is character strings . They have a character set, and values are sorted and compared based on the collation of the character set.
同varchar的行为不同。
table people字段chinese_desc为如下类型
CHINESE_DESC text utf8_unicode_ci
所以使用Java查询和插入 UTF-8字段插入汉字需要encoding 为 iso-8859-1
插入代码:
String SQL="update people set chinese_desc='\u9802\u7d44\u5408\u88fd\u9020' where ENG_desc='DJZHZZ' ;";//\u9802\u7d44\u5408\u88fd\u9020
String UTF8=new String(SQL.getBytes("UTF-8"),"ISO-8859-1");
PreparedStatement stmt=conn.prepareStatement("set names latin1");
stmt.execute(UTF8);
读取:
String value =rset.getString("chinese_desc");
String value4 = new String(value.getBytes("ISO-8859-1"),"UTF-8");
System.out.println(value4+"........");
星期一, 十月 18, 2010
MSSQL 模仿 ROWID 功能
星期三, 九月 01, 2010
ABAP Native SQL 里的Host Variables
Host Vairable翻译为宿主变量或者托管变量,似乎都可以.主要是通过冒号: 来表示的。其他用法和普通ABAP变量或其他structure,element等等一样。没什么区别。
Host variables are global or local variables declared in the ABAP program, or variables that are used in operand positions by native SQL statements. For identification purposes, the variable name has a colon (:) directly in front of it. Instead of specifying a variable itself, you can also specify a field symbol to which the variable is assigned. The specification of a dereferenced data reference variable is not possible.
You can use elementary fields and structures with elementary components as host variables. If a structure is listed in a native SQL statement after INTO, it is converted by the native SQL interface as if its components were listed as individual fields separated by commas.
星期四, 八月 12, 2010
ABAP Label for Operands
- Structured data types or data objects (structure)
A component comp of a structured data type or a structure struct is accessed using the label struct-comp.
- Instances of classes (objects)
The label ref->comp is used to access a component comp of an object. The character -> is the object component selector
- Classes
The label class=>comp can be used to access a static component comp of a class without an instance of the class having to be created. The character => is the class component selector.
- Interfaces
The label
intf~comp
is used to access a component comp of an interface. The character ~ is the interface component selector.
- Escape character for names
The character ! can be written directly before a name in order to distinguish it from an ABAP word of the same name in a statement.
星期二, 八月 10, 2010
获取当前登录用户的profile.
DATA: wa_profiles LIKE LINE OF C_PROFILE.
data it_prof type BAPIPROF occurs 0.
DATA: it_roles TYPE TABLE OF bapiagr,
wa_roles LIKE LINE OF it_roles.
F_USERNAME = SY-UNAME.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME = F_USERNAME
IMPORTING
ADDRESS = S_ADDRESS
TABLES
RETURN = TAB_RETURN
profiles = C_PROFILE
activitygroups = it_roles.
LOOP AT it_roles INTO wa_roles.
write: /,'Roles:',wa_roles-AGR_NAME.
ENDLOOP.
LOOP AT C_PROFILE INTO wa_profiles.
write: /,'Profile::',wa_profiles-BAPIPROF,wa_profiles-BAPIPTEXT.
ENDLOOP.
星期四, 八月 05, 2010
星期五, 七月 30, 2010
ABAP 指针。
SAP ABAP--通过Field-symbols修改内表( same as c and c++ point)
1. 什么是ABAP指针:
在ABAP里面,field symbol就相当于c语言的指针。如果你定义并且分配了相应的结构或者变量给它,其实它就指
向这个结构或者变量的地址,如果修改了field symbol的值,则相应结构或者变量的值也随之更改。
2. 如何定义指针:
基本形式:FIELD-SYMBOLS <fs>.
附加信息:
1. ... TYPE :定义一个数据类型,然后定义指针
2. ... TYPE REF TO :指针指向类或者接口
3. ... TYPE REF TO :指针指向数据结构
4. ... TYPE LINE OF :指针内表的行项目
5. ... LIKE :指针为数据库表类型
6. ... LIKE LINE OF :指针类型为数据库表的行项目
3. 如何分配指针:
(1). ASSIGN f TO .:分配一个指针,包括以下几种类型
1. ... CASTING ... :主要对unicode系统地操作
1a. ... CASTING
1b. ... CASTING TYPE type
1c. ... CASTING ... DECIMALS dec
1d. ... CASTING LIKE f1
2. ... TYPE type :直接指定类型
3. ... DECIMALS dec :指定小数点位数
4. ... RANGE range:指定范围
(2). 分配结构中的某个字段给指针
ASSIGN COMPONENT idx OF STRUCTURE struc TO .
ASSIGN COMPONENT name OF STRUCTURE struc TO .
(3). 分配类的方法给指针
ASSIGN dref->* TO .
(4). 从f开始,是f的n倍长之后的内容分配给指针
ASSIGN f INCREMENT n TO .
(5). 分配局部变量给指针
ASSIGN LOCAL COPY
3a. ASSIGN LOCAL COPY OF f TO .
3b. ASSIGN LOCAL COPY OF INITIAL f TO .
3c. ASSIGN LOCAL COPY OF INITIAL LINE OF itab TO .
4c. ASSIGN LOCAL COPY OF MAIN TABLE FIELD (f) TO .
(6). ASSIGN dynamicJ:动态分配指针
4a. ASSIGN (f) TO .
4b. ASSIGN oref->(f) TO .
4c. ASSIGN (f1)=>(f2) TO .
4d. ASSIGN TABLE FIELD (f) TO .
4e. ASSIGN LOCAL COPY OF MAIN TABLE FIELD (f) TO .
4f. ASSIGN LOCAL COPY OF ... (f) TO .
4. 如何取消分配:
UNASSIGN .
不清楚内表内表到底是itab还是itab2,但是又要访问内表里的第2个字段。所以在loop的时候不能用to到一个结构体,而要用assigning一个指向ANY的指针,然后进行后面的操作。
IF n = 1.
ASSIGN itab[] TO <tab_fs>. " <tab_fs>是指向standard table的
ELSE.
ASSIGN itab2[] TO <tab_fs>.
ENDIF.
LOOP AT <tab_fs> ASSIGNING <wa_fs>.
ASSIGN COMPONENT 2 OF STRUCTURE <wa_fs> TO <field_fs>. ”filed_fs是ANY的
WRITE: / <field_fs>.
ENDLOOP.
具体实现:
1.结构的动态查询
DEFINE SELECT_DATA_TO_WA.
SELECT &1
FROM &2
INTO CORRESPONDING FIELDS OF &3
WHERE (&4).
EXIT.
ENDSELECT.
END-OF-DEFINITION.
2.变量的动态查询
DEFINE SELECT_DATA_TO_VARIANT.
SELECT &1
FROM &2
INTO &3
WHERE (&4).
EXIT.
ENDSELECT.
END-OF-DEFINITION.
3.内表的动态查询
DEFINE SELECT_DATA_TO_VARIANT.
SELECT &1
FROM &2
INTO CORRESPONDING FIELDS OF TABLE &3
WHERE (&4).
EXIT.
ENDSELECT.
END-OF-DEFINITION.
具体程序实现:
DATA: L_FIELD(100) TYPE C,
L_TABLE(10) TYPE C,
L_COND(100) TYPE C.
DATA: I_COND TYPE TALBE OF L_COND.
FIELD-SYMBOLS TYPE ANY.
START-OF-SELECTION.
CONCATENATE 'CARRID' 'CONNID' 'CITYFROM'
INTO L_S
SEPARATE BY SPACE.
CONCATENATE 'CONNID = ' '0123'
INTO L_COND.
APPEND COND TO I_COND.
L_TABLE = 'SPFLI'.
IF IS ASSIGNED.
UNASSIGN .
ASSIGN SPFLI TO .
ELSE.
ASSIGN SPFLI TO .
ENDIF.
SELECT_DATA_TO_WA (L_S) (L_TABLE) I_COND.
=================================================================================
FIELD-SYMBOLS CASTING
REPORT z_barry_fs_casting.
TYPES: BEGIN OF t_date,
year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
END OF t_date.
FIELD-SYMBOLS <fs> TYPE t_date.
ASSIGN sy-datum TO <fs> CASTING.
WRITE: / sy-datum,
/ <fs>-year , / <fs>-month, / <fs>-day.
=================================================================================
光标操作
DATA: w_fname(20) TYPE c,
w_val(10) TYPE c.
PARAMETERS: p1(10) TYPE c,
p2(10) TYPE c,
p3(10) TYPE c.
AT SELECTION-SCREEN.
CHECK sy-ucomm IS INITIAL.
GET CURSOR FIELD w_fname VALUE w_val.
CHECK w_val IS INITIAL. "如果没有输入
CLEAR w_fname.
AT SELECTION-SCREEN OUTPUT.
CASE w_fname.
WHEN 'P1'.
CLEAR w_fname.
SET CURSOR FIELD 'P2'.
WHEN 'P2'.
CLEAR w_fname.
SET CURSOR FIELD 'P3'.
ENDCASE.
======================================================================
ABAP--Field Symbol 的Example(来自SAP的样例)
Full type specification
REPORT demo_field_symbols_type .
DATA: BEGIN OF line,
col1(1) TYPE c,
col2(1) TYPE c VALUE 'X',
END OF line.
FIELD-SYMBOLS <fs> LIKE line.
ASSIGN line TO <fs>.
MOVE <fs>-col2 TO <fs>-col1.
WRITE: <fs>-col1, <fs>-col2.
Forcing structures
REPORT demo_field_symbols_structure .
DATA: wa(10) TYPE c VALUE '0123456789'.
DATA: BEGIN OF line1,
col1(3) TYPE c,
col2(2) TYPE c,
col3(5) TYPE c,
END OF line1.
DATA: BEGIN OF line2,
col1(2) TYPE c,
col2 TYPE sy-datum,
END OF line2.
* obsolete -------------------------------------------------------------
FIELD-SYMBOLS: <f1> STRUCTURE line1 DEFAULT wa,
<f2> STRUCTURE line2 DEFAULT wa.
* correct --------------------------------------------------------------
FIELD-SYMBOLS <f3> LIKE line1.
ASSIGN wa TO <f3> CASTING.
FIELD-SYMBOLS <f4> LIKE line2.
ASSIGN wa TO <f4> CASTING.
* ----------------------------------------------------------------------
WRITE: / <f1>-col1, <f1>-col2, <f1>-col3,
/ <f2>-col1, <f2>-col2.
SKIP.
WRITE: / <f3>-col1, <f3>-col2, <f3>-col3,
/ <f4>-col1, <f4>-col2.
Static assign
REPORT demo_field_symbols_stat_assign .
FIELD-SYMBOLS: <f1> TYPE ANY, <f2> TYPE i.
DATA: text(20) TYPE c VALUE 'Hello, how are you?',
num TYPE i VALUE 5,
BEGIN OF line1,
col1 TYPE f VALUE '1.1e+10',
col2 TYPE i VALUE '1234',
END OF line1,
line2 LIKE line1.
ASSIGN text TO <f1>.
ASSIGN num TO <f2>.
DESCRIBE FIELD <f1> LENGTH <f2>.
WRITE: / <f1>, 'has length', num.
ASSIGN line1 TO <f1>.
ASSIGN line2-col2 TO <f2>.
MOVE <f1> TO line2.
ASSIGN 'LINE2-COL2 =' TO <f1>.
WRITE: / <f1>, <f2>.
Assign with offset
REPORT demo_field_symbols_stat_as_off .
FIELD-SYMBOLS <fs> TYPE ANY.
DATA: BEGIN OF line,
string1(10) VALUE '0123456789',
string2(10) VALUE 'abcdefghij',
END OF line.
WRITE / line-string1+5.
ASSIGN line-string1+5 TO <fs>.
WRITE / <fs>.
ASSIGN line-string1+5(*) TO <fs>.
WRITE / <fs>.
REPORT demo_field_symbols_stat_as_of2 .
FIELD-SYMBOLS <fs> TYPE ANY.
DATA: BEGIN OF line,
a TYPE c VALUE '1', b TYPE c VALUE '2',
c TYPE c VALUE '3', d TYPE c VALUE '4',
e TYPE c VALUE '5', f TYPE c VALUE '6',
g TYPE c VALUE '7', h TYPE c VALUE '8',
END OF line,
off TYPE i,
len TYPE i VALUE 2.
DO 2 TIMES.
off = sy-index * 3.
ASSIGN line-a+off(len) TO <fs>.
<fs> = 'XX'.
ENDDO.
DO 8 TIMES.
off = sy-index - 1.
ASSIGN line-a+off(1) TO <fs>.
WRITE <fs>.
ENDDO.
Dynamic assign
REPORT demo_field_symbols_dynami_as_2 .
TABLES sbook.
DATA: name1(20) TYPE c VALUE 'SBOOK-FLDATE',
name2(20) TYPE c VALUE 'NAME1'.
FIELD-SYMBOLS <fs> TYPE ANY.
ASSIGN TABLE FIELD (name1) TO <fs>.
WRITE: / 'SY-SUBRC:', sy-subrc.
ASSIGN TABLE FIELD (name2) TO <fs>.
WRITE: / 'SY-SUBRC:', sy-subrc.
Assigning field symbols
REPORT demo_field_symbols_dynami_as_3 .
DATA: BEGIN OF s,
a TYPE c VALUE '1', b TYPE c VALUE '2', c TYPE c VALUE '3',
d TYPE c VALUE '4', e TYPE c VALUE '5', f TYPE c VALUE '6',
g TYPE c VALUE '7', h TYPE c VALUE '8',
END OF s.
DATA off TYPE i.
FIELD-SYMBOLS <fs> TYPE ANY.
ASSIGN s-a TO <fs>.
DO 4 TIMES.
off = sy-index - 1.
ASSIGN <fs>+off(1) TO <fs>.
WRITE <fs>.
ENDDO.
Assigning a structure by component
REPORT demo_field_symbols_assign_comp .
DATA: BEGIN OF line,
col1 TYPE i VALUE '11',
col2 TYPE i VALUE '22',
col3 TYPE i VALUE '33',
END OF line.
DATA comp(5) TYPE c VALUE 'COL3'.
FIELD-SYMBOLS: <f1> TYPE ANY, <f2> TYPE ANY, <f3> TYPE ANY.
ASSIGN line TO <f1>.
ASSIGN comp TO <f2>.
DO 3 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE <f1> TO <f3>.
WRITE <f3>.
ENDDO.
ASSIGN COMPONENT <f2> OF STRUCTURE <f1> TO <f3>.
WRITE / <f3>.
Casting with field symbol type
REPORT demo_field_symbols_casting.
TYPES: BEGIN OF t_date,
year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
END OF t_date.
FIELD-SYMBOLS <fs> TYPE t_date.
ASSIGN sy-datum TO <fs> CASTING.
WRITE / sy-datum.
SKIP.
WRITE: / <fs>-year , / <fs>-month, / <fs>-day.
Casting with explicit type
REPORT demo_field_symbols_casting_typ.
TYPES: BEGIN OF t_date,
year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
END OF t_date.
FIELD-SYMBOLS: <fs> TYPE ANY,
<f> TYPE n.
ASSIGN sy-datum TO <fs> CASTING TYPE t_date.
WRITE / sy-datum.
SKIP.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs> TO <f>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
WRITE / <f>.
ENDDO.
Casting with predefined data types
REPORT demo_field_symbols_assign_type .
DATA txt(8) TYPE c VALUE '19980606'.
DATA mytype(1) VALUE 'X'.
FIELD-SYMBOLS <fs> TYPE ANY.
ASSIGN txt TO <fs>.
WRITE / <fs>.
SKIP.
* obsolete -------------------------------------------------------------
ASSIGN txt TO <fs> TYPE 'D'.
WRITE / <fs>.
ASSIGN txt TO <fs> TYPE mytype.
WRITE / <fs>.
SKIP.
* correct --------------------------------------------------------------
ASSIGN txt TO <fs> CASTING TYPE d.
WRITE / <fs>.
ASSIGN txt TO <fs> CASTING TYPE (mytype).
WRITE / <fs>.
Casting decimla places
REPORT demo_field_symbols_assign_deci .
DATA: pack1 TYPE p DECIMALS 2 VALUE '400',
pack2 TYPE p DECIMALS 2,
pack3 TYPE p DECIMALS 2.
FIELD-SYMBOLS: <f1> TYPE ANY ,
<f2> TYPE ANY.
WRITE: / 'PACK1', pack1.
SKIP.
* obsolete -------------------------------------------------------------
ASSIGN pack1 TO <f1> DECIMALS 1.
WRITE: / '<F1> ', <f1>.
pack2 = <f1>.
WRITE: / 'PACK2', pack2.
ASSIGN pack2 TO <f2> DECIMALS 4.
WRITE: / '<F2> ', <f2>.
pack3 = <f1> + <f2>.
WRITE: / 'PACK3', pack3.
<f2> = '1234.56789'.
WRITE: / '<F2> ', <f2>.
WRITE: / 'PACK2', pack2.
SKIP.
* correct --------------------------------------------------------------
ASSIGN pack1 TO <f1> CASTING TYPE p DECIMALS 1.
WRITE: / '<F1> ', <f1>.
pack2 = <f1>.
WRITE: / 'PACK2', pack2.
ASSIGN pack2 TO <f2> CASTING TYPE p DECIMALS 4.
WRITE: / '<F2> ', <f2>.
pack3 = <f1> + <f2>.
WRITE: / 'PACK3', pack3.
<f2> = '1234.56789'.
WRITE: / '<F2> ', <f2>.
WRITE: / 'PACK2', pack2.
Data areas for field symbols
REPORT demo_field_symbols_assign_err .
DATA: text1(10) TYPE c, text2(10) TYPE c, text3(5) TYPE c.
FIELD-SYMBOLS <fs> TYPE ANY.
DO 100 TIMES. "Runtime-Error!
ASSIGN text1+sy-index(1) TO <fs>.
ENDDO.
Data references
REPORT demo_data_reference.
TYPES: BEGIN OF t_struct,
col1 TYPE i,
col2 TYPE i,
END OF t_struct.
DATA: dref1 TYPE REF TO data,
dref2 TYPE REF TO data.
FIELD-SYMBOLS: <fs1> TYPE t_struct,
<fs2> TYPE i.
CREATE DATA dref1 TYPE t_struct.
ASSIGN dref1->* TO <fs1>.
<fs1>-col1 = 1.
<fs1>-col2 = 2.
dref2 = dref1.
ASSIGN dref2->* TO <fs2> CASTING.
WRITE / <fs2>.
GET REFERENCE OF <fs1>-col2 INTO dref2.
ASSIGN dref2->* TO <fs2>.
WRITE / <fs2>.
===========================================================================
ABAP--通过Field-symbols修改内表
report demo_field_symbols_assign_comp .
DATA: BEGIN OF gs_itab,
drph(10) ,
cmsl01(17),
cmsl02(17),
sl01(17),
sl02(17),
END OF gs_itab.
DATA: gt_ita1 LIKE gs_itab OCCURS 0 WITH HEADER LINE.
data gv_zd(15).
FIELD-SYMBOLS <sl> TYPE c.
FIELD-SYMBOLS <cmsl> TYPE c.
FIELD-SYMBOLS <fs> LIKE LINE OF gt_ita1.
DO 15 TIMES.
gt_ita1-drph = SY-INDEX .
gt_ita1-cmsl01 = 2.
append gt_ita1.
enddo.
write 'Before Modify:'.
write:/ 'cmsl01','cmsl02','sl01','sl02'.
loop at gt_ita1.
write:/ '|',gt_ita1-cmsl01,'|',gt_ita1-cmsl02,'|',gt_ita1-sl01,'|' ,gt_ita1-sl02,'|'.
endloop.
loop at gt_ita1 aSSIGNING <fs>.
ASSIGN COMPONENT 'CMSL01' OF STRUCTURE <fs> TO <cmsl>.
ASSIGN COMPONENT 'SL01' OF STRUCTURE <fs> TO <sl>.
move <cmsl> to <sl>.
ASSIGN COMPONENT 'SL02' OF STRUCTURE <fs> TO <sl>.
move <cmsl> to <sl>.
<fs>-CMSL02 = 'A' .
endloop.
write / 'After Modify:'.
loop at gt_ita1.
write:/ '|',gt_ita1-cmsl01,'|',gt_ita1-cmsl02,'|',gt_ita1-sl01,'|' ,gt_ita1-sl02,'|'.
endloop.
注意:ASSIGN TABLE FIELD (f) TO <fs>. 只能用TABLES定义的变量
An important, but frequently misunderstood aspect of ABAP, is the "Field Symbol". But you'll find they aren't mysterious. In fact, they may remind you of some features in popular general-purpose programming languages.
Field symbols allow you to:
** Assign an alias to a data object(for example, a shortened name for data objects structured through several hierarchies
For Example: <fs>-f instead of rec1-rec2-rec3-f)
** Set the offset and length for a string variably at runtime
** Set a pointer to a data object that you determine at runtime (dynamic ASSIGN)
** Adopt or change the type of a field dynamically at runtime
** Access components of a structure (from Release 4.5A) Point to lines of an internal table (process internal tables without a separate work area)
Field symbols in ABAP are similar to pointers in other programming languages. However, pointers (as used in PASCAL or C) differ from ABAP field symbols in their reference syntax.
The statement ASSIGN f to <fs> assigns the field f to field symbol <fs>. The field symbol <fs> then "points" to the contents of field f at runtime. This means that all changes to the
contents of f are visible in <fs> and vice versa. You declare the field symbol <fs> using the statement FIELD-SYMBOLS: <fs>.
Reference syntax
Programming languages such as PASCAL and C use a dereferencing symbol to indicate the difference between a reference and the object to which it refers; so PASCAL would use p^ for a pointer instead of p, C would use *p instead of p. ABAP does not have any such dereferencing symbol.
** In PASCAL or C, if you assign a pointer p1 to a pointer p2, you force p1 to point to the object to which p2 refers (reference semantics).
** In ABAP, if you assign a field symbol <fs1> to a field symbol <fs2>, <fs1> takes the value of the data object to which <fs2> refers (value semantics).
** Field symbols in ABAP are always dereferenced, that is, they always access the referenced data object. If you want to change the reference yourself in ABAP, you can use the ASSIGN statement
to assign field symbol <fs1> to field symbol <fs2>.
星期二, 七月 20, 2010
SAP WD IE 8 Hang system,CPU HIGH 100%问题解决。
经过google得到方法如下:
设置IE 显示固定在100%,而不让IE 8自己调整。
如图,则问题解决.
星期三, 七月 07, 2010
如何建立sap icm web admin访问地址
icmon -a 新建如下用户.
1. As user <sid>adm go to the directory where the executables are kept and call up icmon ‑a pf=<instance profile> .
The following appears:
Maintain authentication file
============================
File name (icmauth.txt): .
2. If you are happy with the default file name, press the enter key, otherwise enter a different file name or path.
3. In the next menu choose a (add user to set).
4. Enter the user name, then the password twice, the group name, the subject of the X.509 certificate (wildcards allowed, and it can be left empty).
User Name: icmadm
Enter Password: *****
Re-enter Password: *****
Group name: admin
Subject Value of Client Cert: CN=template,*
new entry locally created
The user created is in group admin, the user is therefore an administration user without administration authorization. In particular this user can create further users in the Web admin interface.
If you select another group name other than admin, create a monitoring user that can monitor, but not administrate, the ICM/Web Dispatcher.
If you want a user to be able to log on only with the X.509 client certificate, you can enter an x as the password (with queries), which makes the following entry (in the example) in file:
icmadm:x:admin:CN=muster,*
5. Choose s (save changes of set to file), to copy your changes from the local buffer to the authorization file.
6. Choose q, to quit the program.
然后然后icmauth.txt复制到 :D:\usr\sap\SA1\SYS\global\security\data
可以 可以在 SAPGUI用 T-CODE :SMICM 然后从点击 display-All (shift+F5)显示 trace 文件
然后 从web http://localhost:8000/sap/admin 输入用户名,再进入管理UI 了
然后
然后
星期五, 七月 02, 2010
SE80删除一个class出现错误:You cannot perform this action in modification/enhancement mode
来删除CLASS.
COMMIT 和FORCE的值设置为'X'
如图
或者关闭 modification assistant,双击打开class后,选择菜单:
edit menu and select modifications and select "switch off modification assistant".
如下图
星期五, 六月 25, 2010
(fixed)如何清空/删除 SAP MMC SYSLOG?
清空文件:usr\sap\<SID>\DVEBMGS00\log\SLOG00.LOG
使用Ultraedit 打开文件删除里面的所有内容保存空文件即可
ABAP 动态定义select help
编写自己的 trigger POV 事件.更加灵活
*&---------------------------------------------------------------------*
*& Report Z_SEARCH_HELP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_SEARCH_HELP NO STANDARD PAGE HEADING.
TABLES: pa0001.
parameters: ppernr type pa0001-pernr .
DATA: i_return TYPE ddshretval OCCURS 0 WITH HEADER LINE,
c TYPE c VALUE 'S'.
* Search Help for Ppernr-low
AT SELECTION-SCREEN ON VALUE-REQUEST for ppernr.
message 'request value?' type 'I'.
TYPES: BEGIN OF t_pernr,
pernr LIKE pa0001-pernr,
ename LIKE pa0001-ename,
END OF t_pernr.
DATA: it_pa0001 TYPE STANDARD TABLE OF t_pernr WITH HEADER LINE.
SELECT pernr ename from pa0001
INTO CORRESPONDING FIELDS OF TABLE it_pa0001
where pa0001~endda = '99991231' .
* WHERE zsdo~kunnr IN sokunnr.
DELETE it_pa0001 WHERE pernr = '00000000'.
SORT it_pa0001 BY pernr.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'PERNR'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'PERNR'
value_org = c
TABLES
value_tab = it_pa0001
return_tab = i_return.
如何在用户登录时sap时自动执行一特定程序
1)SE37然后如图操作
使用函数 'NAVIGATION_SET_START_TCODE' ,用该函数可以设置用户和一个TCODE,该TCODE当用户登录sap系统后就可以自动执行。sap对应的程 序:ADMIN_SET_START_TRANSACTION_FO
2)使用用户出口(user Exit)
该用户出口的模块名称是:SUSR0001,你可以在该单元里增加你的代码进行相应的控制。.
SAP用户登录增强示例
* Transaction CMOD -> Utiliteis -> SAP Enhancements
* Exit Name SUSR0001
* Double click EXIT_SAPLSUSF_001
* Double click ZXUSRU01
* Insert -> include zsesschk.
** zsesschk limits the number of login sessions per user
* in a certain client
* It runs from user exit SUSR0001 after the SAP Login
* n-1 is the number of concurrent sessions allowed
TABLES: UINFO.
DATA: N TYPE I VALUE 2. "Upper limit of login sessions
DATA: OPCODE TYPE X VALUE 2, I TYPE I, A(60).
DATA: BEGIN OF BDC_TAB1 OCCURS 5.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB1.
DATA: BEGIN OF USR_TABL OCCURS 10.
INCLUDE STRUCTURE UINFO.
DATA: END OF USR_TABL.
* Exclude Limit login by Users
IF SY-UNAME <> 'XXX'
AND SY-UNAME <> 'XXX'.
CALL 'ThUsrInfo' ID 'OPCODE' FIELD OPCODE
ID 'TAB' FIELD USR_TABL-*SYS*.
LOOP AT USR_TABL.
IF SY-UNAME = USR_TABL-BNAME AND SY-MANDT = USR_TABL-MANDT.
I = I + 1.
ENDIF.
ENDLOOP.
IF I >= N.
A = 'You have already '.
A+17(2) = I - 1.
A+19(25) = 'login sessions in client '.
A+44(4) = SY-MANDT.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'UNSUCCESSFUL LOGIN'
TXT1 = A
TXT2 = 'You are not allowed to log in'.
MOVE: 'SAPMSSY0' TO BDC_TAB1-PROGRAM,
'120' TO BDC_TAB1-DYNPRO,
'X' TO BDC_TAB1-DYNBEGIN.
APPEND BDC_TAB1.CLEAR BDC_TAB1.
MOVE: 'BDC_OKCODE' TO BDC_TAB1-FNAM,
'/nex' TO BDC_TAB1-FVAL.
APPEND BDC_TAB1.CLEAR BDC_TAB1.
CALL TRANSACTION 'SM04' USING BDC_TAB1 MODE 'N'.
ENDIF.
ENDIF.
星期一, 六月 14, 2010
Emacs Lisp 如何配置. macrs 文件 c-x -c-f
(setq inferior-lisp-program "d:\\sbcl\\1.0.37\\sbcl.exe")
(require 'slime)
(slime-setup)
(add-to-list 'load-path "D:\\color-theme-6.6.0")
(require 'color-theme)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(color-theme-hober)))
星期六, 六月 12, 2010
Lisp 提示在read之后才出来
(format t "Please enter a number. ")
(let ((val (read)))
(if (numberp val)
val
(ask-number))))
(defvar val)
(setf val (ask-number))
(defparameter *s* (open "f:\\temp\\mytest.txt" :direction :output :if-does-not-exist :create :if-exists :append))
(format *s* "your input:~A~%" val)
(close *s*)
原因:
format 需要输出一个新行后,才会刷新,所以,加入~%
(format t "Please enter a number. ~%")
星期五, 六月 04, 2010
ABAP处理所有异常
语法,
TRY.
... " TRY block (application coding)
CATCH cx_... cx_... ...
... " CATCH block (exception handler)
CATCH cx_... cx_... ...
... " CATCH block (exception handler)
...
CLEANUP.
... " CLEANUP block (cleanup context)
ENDTRY.
如果想处理所有异常,使用
catch cx_root.
- A TRY block, in which exceptions can occur.
This exception block consists of all the statements between the TRY and the CATCH statement. - One or more CATCH blocks for catching exceptions.
These exception blocks are initiated with CATCH and ended with a further CATCH, CLEANUP, or ENDTRY. - A CLEANUP block for cleanup work after the exceptions have been caught.
This statement block is initiated by CLEANUP and ended with ENDTRY. A TRY-ENDTRY structure must not contain more than one CLEANUP block in precisely this position.
星期一, 五月 31, 2010
LISP CDR 和 CAR意思
而 cons 就是透过这两个缓存器而实作的。) Cons 很容易使用:
星期五, 五月 28, 2010
如何在Java Mail中是用Log4j来记录Java Mail Debug 信息?的
但是这个debug是直接输出到System.out的,需要用 >>来截获。
不过Java Mail 提供了setDebugOut(PrintStream)的接口,
就用这个可以实现 Java Mail和 log4j的联合使用
首先编写一个PrintStream的类做一个Bridge 同 Log4j
package com.email;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.log4j.*;
/**
*
* @author U253MIS038
*/
public class LoggingOutputStream extends OutputStream
{
protected boolean hasBeenClosed = false;
protected byte[] buf;
protected int count;
private int bufLength;
public static final int DEFAULT_BUFFER_LENGTH = 2048;
protected Logger logger;
protected Level level;
private LoggingOutputStream()
{
}
public LoggingOutputStream(Logger log, Level level)
throws IllegalArgumentException {
if (log == null) {
throw new IllegalArgumentException("cat == null");
}
if (level == null) {
throw new IllegalArgumentException("priority == null");
}
this.level = level;
logger = log;
bufLength = DEFAULT_BUFFER_LENGTH;
buf = new byte[DEFAULT_BUFFER_LENGTH];
count = 0;
}
public void close()
{
flush();
hasBeenClosed = true;
}
public void write(final int b) throws IOException
{
if (hasBeenClosed) {
throw new IOException("The stream has been closed.");
}
if (count == bufLength)
{
final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH;
final byte[] newBuf = new byte[newBufLength];
System.arraycopy(buf, 0, newBuf, 0, bufLength);
buf = newBuf;
bufLength = newBufLength;
}
buf[count] = (byte) b;
count++;
}
public void flush()
{
if (count == 0)
{
return;
}
if (count == 1 && ((char) buf[0]) == '\n')
{
reset();
return;
}
final byte[] theBytes = new byte[buf.length];
System.arraycopy(buf, 0, theBytes, 0, count);
logger.log(level, new String(theBytes));
reset();
}
private void reset()
{
count = 0;
}
}
2,然后再调用Java Mail中使用如下方法实现了定向
static Logger log = Logger.getLogger( email.class );
Properties props = System.getProperties();
config = new PropertiesConfiguration(PROP_FILE);
String mailip = config.getString("EMAIL_SERVER_IP");
props.put("mail.smtp.host", mailip);
Session session = Session.getInstance(props, null);
session.setDebugOut(new PrintStream(new LoggingOutputStream(Logger.getRootLogger(),Level.DEBUG), true));
session.setDebug(enableDebug);
星期一, 五月 24, 2010
java 如何确定一个对象是否数组?
Java array reflection: isArray vs. instanceof
那个方法好呢?if(obj.getClass().isArray()) {}
and
if(obj instanceof Object[]) {}
| In general, use the At the JVM level, the The reflective approach ( There are two special cases: null references and references to primitive arrays. A null reference will cause Applied to a primitive array, the |
Ifobjis of typeint[]say, then that will
have an arrayClassbut not be an instance ofObject[].
So what do you want to do withobj. If you are going to
cast it, go withinstanceof. If you are going to use
reflection, then use.getClass().isArray().
总结:
isArray的方位更加广泛。
instance Object[]不能确别int[]等数组。
所以,那个更好,要看自己的具体情况了
星期六, 五月 15, 2010
Lisp命名规则2
低级函数用%开始和技术(%SUM%).语言标准名字的定义只允许用字母(A-Z)和*,+,-,/,1,2,<,=,> &
self-evaluating:
自执行
最重要的两个自执行常量:T和NIL代表 true和false.
另一类最重要的自执行符号是关键词符号.其名字以:开始
最基本的程序组件:
函数,变量,及宏
function,variable,macro
星期五, 五月 14, 2010
Lisp的命名
的名字是否用在变量,函数或其它东西一无所知。.它只是按照字符序列读出并被代表一个对象的名字。
几乎所有的字符都可用在名字中.空白字符不行,因为在list中元素也是用空白字符来分割的.
数字也可以用在名字中的一部分而不是解释成一个数字.相似的,名字可以包含一个句号(.),但无法阅读
只包含一个句号的名字。10个字符用于其他目的而不能在名字中出现:
- 1.开始和结束括号() open and close parentheses
- 2.双引号和单引号 "' double and single quotes
- 3.反引号(`)backtick
- 4.逗号 comma,
- 5.冒号: colon
- 6.分号;semicolon
- 7.反斜线 \ backslash
- 8.竖线| vertical bar
星期一, 五月 10, 2010
Re: Lisp注释语句.
缩进规则:
函数调用形式参数对齐
宏和特殊形式针对最后一个左括号缩进两格
;;;; 文件级别注释
;;; 段落级别注释
;; 函数内部代码注释
; 函数内部代码单行注释,放在代码后面
在阅读 Practical Common Lisp书的时候,突然想到LISP的注释符号应该是如何写呢?
google了下。
http://www.cc.gatech.edu/computing/classes/cs2360/ghall/style/com_mechanics.html
单句注释;分号表示 ;;;header
块注释 #|
Notes:zh
#
另外一种非常规的注释,是在代码中用“ ”来表示,比如下列代码(defun mumble_fcn ( arg1 arg2 )
"This function takes two arbitrary arguments and returns some
arbitrarily random result. NOTE: both arguments should be non-nil."
(do-random-thing (do-random-thing arg1 ) arg2 ))
星期五, 五月 07, 2010
SAP NetWeaver Composition Environment 7.2 Trial Version 安装 步骤 Create secure store 出现错误
首先下载了jdk 1.6.0_07之上的版本,我下载的是 1.6.0_20版本,并且下载了jce 6的文件,很小只有8K.
安装到步骤时候出现错误:
安装 :18/29的时候,Create secure store
根据提示打开错误日志:
C:\Program Files\sapinst_instdir\NW72_DEV_ADA\SERVER\SecureStoreCreate.log
发现如下提示:
FATAL: Main class "com.sap.security.core.server.secstorefs.SecStoreFS" cannot be started:
FATAL: java.lang.ExceptionInInitializerError
at javax.crypto.Cipher.getInstance(DashoA13*..)
at javax.crypto.Cipher.getInstance(DashoA13*..)
at iaik.security.provider.IAIK.a(Unknown Source)
at iaik.security.provider.IAIK.addAsJDK14Provider(Unknown Source)
at iaik.security.provider.IAIK.addAsJDK14Provider(Unknown Source)
at com.sap.security.core.server.secstorefs.Crypt.<clinit>(Crypt.java:85)
at com.sap.security.core.server.secstorefs.SecStoreFS.setSID(SecStoreFS.java:177)
at com.sap.security.core.server.secstorefs.SecStoreFS.handleCreate(SecStoreFS.java:838)
at com.sap.security.core.server.secstorefs.SecStoreFS.main(SecStoreFS.java:1308)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sap.engine.offline.OfflineToolStart.main(OfflineToolStart.java:161)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.SunJCE_b.<clinit>(DashoA13*..)
... 14 more
Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
at javax.crypto.SunJCE_b.i(DashoA13*..)
at javax.crypto.SunJCE_b.g(DashoA13*..)
at javax.crypto.SunJCE_b$1.run(DashoA13*..)
at java.security.AccessController.doPrivileged(Native Method)
... 15 more
FATAL: com.sap.engine.offline.OfflineToolStart will abort now with exitcode 2
Solution:
copy
C:\Program Files\Java\jre6\lib\security 下所有文件到sap临时安装JVM目录下,
如果有提示是否需要覆盖,不要覆盖SAP原来的文件。
to
C:\Program Files\sapinst_instdir\NW72_DEV_ADA\SERVER\sapjvm\sapjvm_6\jre\lib\security
Lisp注释语句.
google了下。
http://www.cc.gatech.edu/computing/classes/cs2360/ghall/style/com_mechanics.html
单句注释;分号表示 ;;;header
块注释 #|
Notes:zh
#
另外一种非常规的注释,是在代码中用“ ”来表示,比如下列代码
(defun mumble_fcn ( arg1 arg2 )
"This function takes two arbitrary arguments and returns some
arbitrarily random result. NOTE: both arguments should be non-nil."
(do-random-thing (do-random-thing arg1 ) arg2 ))
星期二, 四月 20, 2010
数据库Auto time stamp字段
ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
MSSQL:支持:
版本戳 timestamp 字段类型。
星期一, 四月 19, 2010
星期二, 一月 26, 2010
jsp code too large for try statement
在JAVA_OPTS里加入以下变量:
1.java -Dcom.sun.tools.javac.main.largebranch=true
java lib\tools.jar 包内
注意,如果装有多个版本的JDK,需要通过设置JAVA_HOME来指明使用的JDK的路径
只是在path中加入是不够的。
星期三, 一月 06, 2010
Linux文件名包含特殊字符无法使用通配符:Argument list too long
会出现:Argument list too long错误
简单解决办法,同find 一起使用
find . -exec grep -l "搜索字符" "{}" \;
列出包含 “搜索字符”的文件名
星期二, 十二月 15, 2009
IE getElementById display
Could not get the display property. Invalid argument
使用obj.style.display='none'
出现错误:
Could not get the display property. Invalid argument
function hider() {
var label, control;
if(document.getElementById && (label = document.getElementById('hidden1'))
&& (control = document.getElementById('hidden2'))
&& label.style && control.style)
{
label.style.display = control.style.display
= ('none' == label.style.display) ? '' : 'none';
}
星期二, 十二月 01, 2009
clear window update store directory
clear window update store directory
%systemdrive%\windows\SoftwareDistribution
clear
星期五, 十一月 20, 2009
wxwidgets convet wxString to C Style char
wxString 提供的 c_str,fn_str,char_str等都source code encoding相关
如果想转换成功,必须注意编译的encoding选择。
比如如果打开了unicode的编译选择,wxWidgets想从一个wxString得到一个 c Style的char *
最安全的方法为:
wxString asc=wxString("this is 汉字");
char *=asc.mb_str(wxConvUTF8);
curl 如何在mingw下使用

首先从http://curl.haxx.se/下载最新的源代码包。
比如 curl-7.19.7.tar.gz
1.然后将其展开到一个目录下,将来将要引用这里面的内容,include和lib
2.进入lib目录下:运行 mingw32-make -f Makefile.m32 编译生成所有的库.libcur.a及libcurl.dll等
3.进入/curl/docs/examples/ 编译个测试程序:
gcc -DCURL_STATICLIB -I ../../include -L ../../lib simple.c -o simple -lcurl -lws2_32 -lwinmm
运行simple.exe,能够正常运行。
CodeBlocks 里如何使用libcurl 实现static link(静态连接,避免运行使用libcurl.dll)
在codeblocks里可以在项目属性build options link setting 里加入 libcur.a的包,以及定义编译使用静态链接的属性
CURL_STATICLIB或者在使用的代码里加入:
#define CURL_STATICLIB
codeblock配置如图:
注意:如果编译的时候出现符号错误:
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_initA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_simple_bind_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_search_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_first_entry'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_get_dnA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_first_attributeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_get_values_lenA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_value_free_len'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_memfreeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_next_attributeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_memfreeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_next_entry'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_unbind_s'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_msgfree'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_simple_bind_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ber_free'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
这是需要连接mingw32的 ldap32 .这个需要在项目的build option link lib 里加入:
D:\MinGW\lib\libwldap32.a,顺序要注意.
libwldap32.a必须在libcurl.a的后面
星期一, 十一月 16, 2009
Windows rundll32 utility
Any program using the Windows file association mechanism can be started with the rundll32 utility.
用一个编辑器,打开一个默认后缀的文件:
RUNDLL32.EXE SHELL32.DLL,OpenAs_RunDLL c:\temp\a.txt
ere a list of what is available rundll32 shell32,Control_RunDLL Run The Control Panel
rundll32 shell32,Control_RunDLL X Start applet X of Control Panel
("X" = any CPL filename)
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,4 Regional setting, Date tab
rundll32 shell32,OpenAs_RunDLL \dir\filename.txt Open The 'Open With...' Window
rundll32 shell32,ShellAboutA Info-Box Open 'About Window Window'
rundll32 shell32,Control_RunDLL desk.cpl Open Display Properties
rundll32 user,cascadechildwindows Cascade All Windows
rundll32 user,tilechildwindows Minimize All Child-Windows
rundll32 user,repaintscreen Refresh Desktop
rundll32 keyboard,disable Lock The Keyboard
rundll32 mouse,disable Disable Mouse
rundll32 user,swapmousebutton Swap Mouse Buttons
rundll32 user,setcursorpos Set Cursor Position To (0,0)
rundll32 user,wnetconnectdialog Show 'Map Network Drive' Window
rundll32 user,wnetdisconnectdialog Show 'Disconnect Network Disk' Window
rundll32 user,disableoemlayer Display The BSOD (blue screen of death)Window
rundll32 diskcopy,DiskCopyRunDll Show Copy Disk Window
rundll32 rnaui.dll,RnaWizard Run 'Internet Connection Wizard'
rundll32 shell32,SHFormatDrive Run 'Format Disk (A)' Window
rundll32 shell32,SHExitWindowsEx -1 Cold Restart Of Windows Explorer
rundll32 shell32,SHExitWindowsEx 1 Shut Down Computer
rundll32 shell32,SHExitWindowsEx 0 Logoff Current User
rundll32 shell32,SHExitWindowsEx 2 Windows9x Quick Reboot
rundll32 krnl386.exe,exitkernel Force Windows 9x To Exit (no confirmation)
rundll32 rnaui.dll,RnaDial "MyConnect" Run 'Net Connection' Dialog
rundll32 msprint2.dll,RUNDLL_PrintTestPage Choose & Print Test Page Of Current Printer
rundll32 user,setcaretblinktime Set New Cursor Rate Speed
rundll32 user, setdoubleclicktime Set New DblClick Speed (Rate)
rundll32 sysdm.cpl,InstallDevice_Rundll Hardware installation wizard
rundll32 user,MessageBeep Default beep sound
rundll32 user32.dll,MessageBeep Default beep sound (XP)
rundll32 shell32.dll,Control_RunDLL appwiz.cpl Add/remove programs
rundll32 shell32.dll,Control_RunDLL timedate.cpl,,0 Date/time settings
rundll32 shell32.dll,Control_RunDLL odbccp32.cpl ODBC settings
rundll32.exe url.dll,FileProtocolHandler http:\\www.rgagnon.com
rundll32.exe url.dll,FileProtocolHandler c:\mypdf.pdf
Open the associated application
rundll32 amovie.ocx,RunDll /play /close c:\mymovie.mpg
Play multimedia (movie or sound)
Rundll32.exe powrprof.dll,SetSuspendState Sleep Put the computer in Sleep mode
Privacy (IE)
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 Internet temporary files
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 Cookies
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 1 History
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 16 Forms Data
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 Passwords
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 Delete everything
星期二, 十一月 03, 2009
mysql get table index SQL command
1.show index from tablename
2.select * from information_schema.statistics where table_name='tableName' ;
星期一, 十一月 02, 2009
订阅:
博文 (Atom)
使用obj.style.display='none'
出现错误:
Could not get the display property. Invalid argument
function hider() {
var label, control;
if(document.getElementById && (label = document.getElementById('hidden1'))
&& (control = document.getElementById('hidden2'))
&& label.style && control.style)
{
label.style.display = control.style.display
= ('none' == label.style.display) ? '' : 'none';
}
星期二, 十二月 01, 2009
clear window update store directory
%systemdrive%\windows\SoftwareDistribution
clear
星期五, 十一月 20, 2009
wxwidgets convet wxString to C Style char
如果想转换成功,必须注意编译的encoding选择。
比如如果打开了unicode的编译选择,wxWidgets想从一个wxString得到一个 c Style的char *
最安全的方法为:
wxString asc=wxString("this is 汉字");
char *=asc.mb_str(wxConvUTF8);
curl 如何在mingw下使用
首先从http://curl.haxx.se/下载最新的源代码包。
比如 curl-7.19.7.tar.gz
1.然后将其展开到一个目录下,将来将要引用这里面的内容,include和lib
2.进入lib目录下:运行 mingw32-make -f Makefile.m32 编译生成所有的库.libcur.a及libcurl.dll等
3.进入/curl/docs/examples/ 编译个测试程序:
gcc -DCURL_STATICLIB -I ../../include -L ../../lib simple.c -o simple -lcurl -lws2_32 -lwinmm
运行simple.exe,能够正常运行。
CodeBlocks 里如何使用libcurl 实现static link(静态连接,避免运行使用libcurl.dll)
在codeblocks里可以在项目属性build options link setting 里加入 libcur.a的包,以及定义编译使用静态链接的属性
CURL_STATICLIB或者在使用的代码里加入:
#define CURL_STATICLIB
codeblock配置如图:
注意:如果编译的时候出现符号错误:
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_initA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_simple_bind_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_search_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_first_entry'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_get_dnA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_first_attributeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_get_values_lenA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_value_free_len'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_memfreeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_next_attributeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_memfreeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_next_entry'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_unbind_s'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_msgfree'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_simple_bind_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ber_free'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
这是需要连接mingw32的 ldap32 .这个需要在项目的build option link lib 里加入:
D:\MinGW\lib\libwldap32.a,顺序要注意.
libwldap32.a必须在libcurl.a的后面
星期一, 十一月 16, 2009
Windows rundll32 utility
用一个编辑器,打开一个默认后缀的文件:
RUNDLL32.EXE SHELL32.DLL,OpenAs_RunDLL c:\temp\a.txt
ere a list of what is available
rundll32 shell32,Control_RunDLL Run The Control Panel
rundll32 shell32,Control_RunDLL X Start applet X of Control Panel
("X" = any CPL filename)
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,4 Regional setting, Date tab
rundll32 shell32,OpenAs_RunDLL \dir\filename.txt Open The 'Open With...' Window
rundll32 shell32,ShellAboutA Info-Box Open 'About Window Window'
rundll32 shell32,Control_RunDLL desk.cpl Open Display Properties
rundll32 user,cascadechildwindows Cascade All Windows
rundll32 user,tilechildwindows Minimize All Child-Windows
rundll32 user,repaintscreen Refresh Desktop
rundll32 keyboard,disable Lock The Keyboard
rundll32 mouse,disable Disable Mouse
rundll32 user,swapmousebutton Swap Mouse Buttons
rundll32 user,setcursorpos Set Cursor Position To (0,0)
rundll32 user,wnetconnectdialog Show 'Map Network Drive' Window
rundll32 user,wnetdisconnectdialog Show 'Disconnect Network Disk' Window
rundll32 user,disableoemlayer Display The BSOD (blue screen of death)Window
rundll32 diskcopy,DiskCopyRunDll Show Copy Disk Window
rundll32 rnaui.dll,RnaWizard Run 'Internet Connection Wizard'
rundll32 shell32,SHFormatDrive Run 'Format Disk (A)' Window
rundll32 shell32,SHExitWindowsEx -1 Cold Restart Of Windows Explorer
rundll32 shell32,SHExitWindowsEx 1 Shut Down Computer
rundll32 shell32,SHExitWindowsEx 0 Logoff Current User
rundll32 shell32,SHExitWindowsEx 2 Windows9x Quick Reboot
rundll32 krnl386.exe,exitkernel Force Windows 9x To Exit (no confirmation)
rundll32 rnaui.dll,RnaDial "MyConnect" Run 'Net Connection' Dialog
rundll32 msprint2.dll,RUNDLL_PrintTestPage Choose & Print Test Page Of Current Printer
rundll32 user,setcaretblinktime Set New Cursor Rate Speed
rundll32 user, setdoubleclicktime Set New DblClick Speed (Rate)
rundll32 sysdm.cpl,InstallDevice_Rundll Hardware installation wizard
rundll32 user,MessageBeep Default beep sound
rundll32 user32.dll,MessageBeep Default beep sound (XP)
rundll32 shell32.dll,Control_RunDLL appwiz.cpl Add/remove programs
rundll32 shell32.dll,Control_RunDLL timedate.cpl,,0 Date/time settings
rundll32 shell32.dll,Control_RunDLL odbccp32.cpl ODBC settings
rundll32.exe url.dll,FileProtocolHandler http:\\www.rgagnon.com
rundll32.exe url.dll,FileProtocolHandler c:\mypdf.pdf
Open the associated application
rundll32 amovie.ocx,RunDll /play /close c:\mymovie.mpg
Play multimedia (movie or sound)
Rundll32.exe powrprof.dll,SetSuspendState Sleep Put the computer in Sleep mode
Privacy (IE)
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 Internet temporary files
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 Cookies
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 1 History
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 16 Forms Data
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 Passwords
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 Delete everything
星期二, 十一月 03, 2009
mysql get table index SQL command
2.select * from information_schema.statistics where table_name='tableName' ;