level 8
unit pchar_unit;
interface
uses strings;
type avarsize=0..63;
plast=record//动态数组类型
dobuild:boolean;
lastsize:qword;
varsize:avarsize;
last:pchar;
end;
procedure buildlast(var thelast:plast;thelastsize:qword;thevarsize:longword);
//建立动态数组thelast,下标为[1..thelastsize],每个元素长thevarsize字节。
procedure buildlast_from(var thelast:plast;thelastsize:qword;thevarsize:longword;from:pointer);
//建立动态数组,并用form处的元素填充入数组首部。(用于正常数组与它的转换)
procedure buildlast_fill(var thelast:plast;thelastsize:qword;thevarsize:longword;avar:int64);
//建立动态数组,用avar填充每一个元素。(用于清零)
procedure edit(var thelast:plast;x:qword;date:int64);
//编辑thelast中第x个元素为data。
procedure lastfill(var thelast:plast;thevar:int64);
//用thevar填充每一个元素。(用于清零)
procedure dislast(var thelast:plast);
//释放thelast。
function size(thelast:plast):qword;
//获取thelast的下标数量。
function varsize(thelast:plast):avarsize;
//获取thelast每个元素的长度(字节)。
function dobuild(thelast:plast):boolean;
//判断thelast是否建立。
function get(thelast:plast;x:qword):int64;
//获取thelast的第x个元素
function copy(thelast:plast;x,y:qword):plast;
//获取thelast从下标x到下标y的子数组
2017年04月22日 06点04分
3
//请配合强之类转换使用
2017年04月22日 06点04分
百度偏说我在发广告,实现部分发不出来了
![[怒]](/static/emoticons/u6012.png)
!
2017年04月22日 06点04分
level 8
新增函数:
function getpchar(thelast:plast):pchar;
//强制转换动态数组为pchar,例子:数值100255转换为字符ord(10025)。
要不吧友要看什么函数的实现,我再发出来?
2017年04月22日 12点04分
4
错了,是chr(10025)。
2017年04月24日 05点04分
level 8
使用例子:用本单元的数组输出1至10:
uses pchar_unit;
var l:plast;
a:array[1..10]of shortint;
i:shortint;
begin
for i:=1 to 10 do a[i]:=i;//先初始化数组
buildlast_from(l,10,sizeof(a[1]),@a);
//从a数组的首地址开始,取10个元素,每个元素为a的每个元素的大小,存入l中。
for i:=1 to 10 do write(get(l,i),' ');//依次输出
end.
输出:1 2 3 4 5 6 7 8 9 10
2017年04月22日 12点04分
5
level 8
新的版本已上传。
新增函数:
function merge(thelast1,thelast2:plast):plast;
//连接并返回thelast1和thelast2
!!!!!函数改动:copy函数改为pascal string的copy的风格,不再这么直观了
大幅改动:把plast的储存方式反转了,但兼容上一版本。
代码量增加到了155行。
2017年04月26日 12点04分
11
感叹号表示警告的意思。
2017年04月26日 12点04分