推荐_bug str_replace用多了会报错._产供销
| 作者 |
|
ayangzhi [个人空间]
    注册  2010-07-18 发贴数 1070 精华贴 1 原创贴 2 来自 状态 正常
级别 贵宾 |
|
|
有客户写代码, 执行的时候有报错. 调试之后发现是str_replace这个函数存在问题. 附代码, 在脚本工具中执行就会报错. int test() { return 1; }; int main() { string a_str,a_loc,a_qty; int i,j,j_count; for(i = 1 ; i < 2; i++){ a_str = '10E-2-04:280/40-0710:803/400-012:307/40-0:07/408-2-21 :70/46-910:300/407-12:20/408-41:880/409 -2:270/40-120:200/41-231:060/42-3-7:20/40:610'; a_str = str_replace(a_str,'/',','); db_select_area(2); db_free_cur_area(); str_lst_to_db(a_str); db_add_field('loc'); db_add_field('qty'); db_set_field_type(2,'I'); j_count = db_row_count(); for (j = 0; j < j_count; j++) { db_go_row(j); a_str = db_res(0); a_loc = str_get_sub(a_str,0,str_pos(a_str,':')); db_set_value_ext('loc',a_loc); a_qty = str_replace(a_str,a_loc + ':',''); // 注释这一行就不会报错. //a_qty = str_get_sub(a_str,str_pos(a_str,':')+1,strlen_n(a_str)-str_pos(a_str,':')); db_set_value_ext('qty',a_qty); } } db_show(); return 1; }; |
|
 |
于 2026-11-10 15:29 被 ayangzhi 修改

杨清云,承接商贸管理、人力资源实施、综合管理实施服务.
可扩展开发WEB, 物联网, 大屏展示报表, 移动端, 微信公众号等.
联系QQ:13836962 TEL:13058180007
|
|
qf2016 [个人空间] QQ名 meng 113779009
      注册  2016-01-17 发贴数 3118 精华数 0 原创贴 0 来自 状态 正常
级别 版主 |
|
|
|