t:=STRRIGHT(STKLABEL ,2);
z:=STRTRIMRIGHT(STKLABEL ,t );//截取出品种名称,如AL,RB
上面是取得当前品种是那个品种,是al还是rb
下面这部分是拼接合约代码的代码
从01拼接到12
for i=1 to 12 do
begin
if i<10 then temp:=STRCAT(z,'0'+NUMTOSTR(i,0)); else if then temp:=STRCAT(z,NUMTOSTR(i,0));//拼接品种代码名称
//使用temp的代码
end
t:=STRRIGHT(STKLABEL ,2);
z:=STRTRIMRIGHT(STKLABEL ,t );//截取出品种名称,如AL,RB
//n是从1到12.m也是1到12. 假设这2变量个是你比较之后取到的最大和次大合约对应的数值(1-12)。
if n<10 then k1code:=STRCAT(z,'0'+NUMTOSTR(n,0)); else if then k1code:=STRCAT(z,NUMTOSTR(n,0));//拼接品种代码名称
if m<10 then k2ode:=STRCAT(z,'0'+NUMTOSTR(m,0)); else if then k2code:=STRCAT(z,NUMTOSTR(m,0));//拼接品种代码名称
k1:callstock(k1code,vtclose,6,0);
k2:callstock(k2code,vtclose,6,0);//callstock参数你根据需求自己可以改下
我测试都正常啊, 你是不是改了什么。