这是什么意思-不能将空字符串用作Tcl上"*"的操作数?如何解决 [英] What does it mean -can't use empty string as operand of "*" on tcl-? how to resolve

查看:69
本文介绍了这是什么意思-不能将空字符串用作Tcl上"*"的操作数?如何解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Tcl脚本,如下所示。

代码工作得非常好;我之前测试了几个输入,但是输入文件Defect.csv有问题。 我尝试删除空格、行并使用unix2dos转换为Unix格式,但是,我收到此错误-无法使用空字符串作为"*"的操作数-

我可以看到格式仍然混乱。我相信由于空格的原因,它不能识别"Y"。 我尝试了以下操作,尝试删除空格/制表符 CAT覆盖VGSnets.csv|sed‘s/g’ SED%s/g"覆盖VGSnets.csv 但是,这并不能解决这个问题。有什么建议吗?

请参阅输入

X       ,       Y
5568687 ,       260755
5568687 ,       259891
5568687 ,       259999
5568687 ,       260755

脚本:

set x1 [lindex $coords 0]
set y1 [lindex $coords 1]
#The coordinates are to be converted into angstroms 
set x2 [expr {int($x1*10)}]
set y2 [expr {int($y1*10)}]
foreach nets [::GetNetsInRegion $x2 $y2 $x2 $y2 vcg temp] 
{puts $outfile $nets foreach masterclose  
[::cadnavapi::layoutAPI::GetMasterCellName $nets]
{puts $outfile $master}}}} $outfile

推荐答案

can't use empty string as operand of "*"
如果用于任何表达式的任一操作数为空,则Tcl将引发上述错误。

% set x1 4
4
% set x2 [expr {int($x1*10)}]
40
% set x1 {}
% set x2 [expr {int($x1*10)}]
can't use empty string as operand of "*"
%

在您的代码中,您将获得变量x1y1,如下所示

set x1 [lindex $coords 0]
set y1 [lindex $coords 1]

添加检查以确保不为空,如

if {$x1 eq {} || $y1 eq {}} {
    puts "Empty records"
    exit 1
}

这篇关于这是什么意思-不能将空字符串用作Tcl上"*"的操作数?如何解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆