铁路车号读取 - IE
来源:互联网 发布:哪些外卖软件首单立减 编辑:程序博客网 时间:2024/04/28 14:32
前文已经介绍了《使用IE测试COM》,那么我们用一个实际的实例来使用他。
在这之前,我们需要了解2个Javascript函数:
- replace(regexp/substr,replacement)
使用这个函数来替换多余的空格。
str.replace(/\s/g, "");
- split(separator,howmany)
字符串转换成字符数组。
string.split(",");
一、js部分
我们把所有的方法放到一个对象(RepoInfo)中。
var RepoInfo = { };
1. 获取对象
RepoInfo.getObj = function(objName) {return new ActiveXObject(objName);};
2. 获取数组
RepoInfo.getArray = function(str) {var ret = new Array(16);var string = str.replace(/\s/g, "");ret = string.split(",");return ret;};
3. 解码字串
(1)输入字串校验
如果字串空,退出。
(2)输出框清空
每次赋值前,清空。
(3)执行COM中的方法
在获取对象非空的情况下,执行。
RepoInfo.decode = function(string) {if (string == null) return;var obj = RepoInfo.getObj("repoInfo.LabelInfo");var edtView = document.getElementById("edtView");edtView.value = " ";var str = RepoInfo.getArray(string);if (obj != null)edtView.value = obj.getInfo(str);};
二、html部分
1. 按钮事件
从输入框获取字串作为js方法的输入参数,注意:两种引号的配合使用。
<input type="button" id="btnOk" value="执行数据解析" onClick="RepoInfo.decode(document.getElementById('edtData').value)" />
2. 页面效果
标签数据:
执行结果:
三、源代码(含js代码)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>报文数据信息 - IE</title><script type="text/javascript">var RepoInfo = {};RepoInfo.getObj = function(objName) {return new ActiveXObject(objName);};RepoInfo.getArray = function(str) {var ret = new Array(16);var string = str.replace(/\s/g, "");alert(string);ret = string.split(",");return ret;};RepoInfo.decode = function(string) {if (string == null) return;var obj = RepoInfo.getObj("repoInfo.LabelInfo");var edtView = document.getElementById("edtView");edtView.value = " ";var str = RepoInfo.getArray(string);if (obj != null)edtView.value = obj.getInfo(str);};</script></head><body> <textarea name="note" cols="98" rows="7" readonly="readonly"> 注意:本测试只能运行在IE浏览器! 首先,要注册Dll(regsvr32 repoInfo.dll); 然后,从“BinJiang_2005.rep”(滨江站),复制行数据到“标签数据”框。 示例(固定格式): 0xD3, 0x05, 0x94, 0x84, 0x00, 0x13, 0x51, 0x2F, 0x59, 0x34, 0x57, 0x45, 0x58, 0x50, 0x41, 0x98</textarea><br><br>标签数据:<input type="text" id="edtData" size="98" /><br><br>执行结果:<input type="text" id="edtView" size="50" /><br><br> <input type="button" id="btnOk" value="执行数据解析" onClick="RepoInfo.decode(document.getElementById('edtData').value)" /></body></html>
编后话:
国内只有两家正规的铁路车号开发机构(所/企业):远望谷和威克公司。
参考文档(W3School):
1. replace 方法
2. RegExp 对象
3. split 方法
0 0
- 铁路车号读取 - IE
- 铁路现代化技术系统整理(四)之车号识别系统
- c算法-找车号
- 车号的正则表达式
- js读取本地文件(IE)
- C#读取IE的Cache
- 铁路图
- 铁路限界
- 铁路SLD
- 铁路调度
- java 根据线索计算车的车号
- IE编程——读取IE窗口信息
- IE编程——读取IE窗口信息
- C#读取IE的Cache(转)
- IE和FF下读取XML文件
- js 读取xml 兼容ff和ie
- IE 兼容 Javascript 读取checkbox的值
- 从 IE 中读取 Cookie 信息
- Eclipse 集成maven 提示错误
- X264 related resource
- 设计模式(4)——Factory method(工厂方法)
- Sum root to leaf number - LeetCode
- php数组函数相关操作
- 铁路车号读取 - IE
- Andorid实现Toast覆盖上一个文本
- 最长公共子序列问题
- 今天学习时突然联想到这样一个有趣但无用的问题:利用C语言(不能是其他语言)求两个整数的较大/小值-----要求不用if、三目?、switch、循环、数组、加减乘除求余、位运算符以及任何库函数
- 第66题 4Sum
- 软件人生之这些年做项目带新人的经验总结 - 仅供参考
- NSString转Byte[]
- world文件读写
- 从今天开始