如何剪切字符串并将其放到下一行

时间:2014-05-21 11:21:59

标签: tcl

我创建了一个tcl策略,我的最后一行是一个长字符串,如下所示;

set tpl_def(0) "$displacement_tpl_def~$pressure_tpl_def~$vibration_tpl_def~$temperature_tpl_def~$load_tpl_def~idling_tpl_def~miles_gallon_tpl_def~engine_temp_tpl_def~engine_speed_tpl_def~accelerator_position_tpl_def~vehicle_speed_tpl_def~miles_per_gallon_tpl_def~engine_intake_manifold_pressure_tpl_def~engine_intake_manifold_temp_tpl_def~vehicle_speed_mph_tpl_def"

现在,当我尝试运行此策略时,我的路由器切断了大约三分之二的字符串。有没有办法可以剪切字符串并在下一行继续播放?

例如像Java一样,你会做这样的事情;

set tpl_def(0) "$displacement_tpl_def~$pressure_tpl_def~$vibration_tpl_def~$temperature_tpl_def~$load_tpl_"
+"def~idling_tpl_def~miles_gallon_tpl_def~engine_temp_tpl_def~engine_speed_tpl_def~accelerator_position_tpl_def~vehicle_speed_tpl_def~"
+ "miles_per_gallon_tpl_def~engine_intake_manifold_pressure_tpl_def~engine_intake_manifold_temp_tpl_def~vehicle_speed_mph_tpl_def"

有没有办法在tcl中做类似的事情?

1 个答案:

答案 0 :(得分:2)

你可以使用行继续,但是会在字符串中插入一个空格来代替反斜杠 - 换行符 - 空格。

set tpl_def(0) "$displacement_tpl_def~$pressure_tpl_def~$vibration_tpl_def~$temperature_tpl_def~\
$load_tpl_def~idling_tpl_def~miles_gallon_tpl_def~engine_temp_tpl_def~\
engine_speed_tpl_def~accelerator_position_tpl_def~vehicle_speed_tpl_def~\
miles_per_gallon_tpl_def~engine_intake_manifold_pressure_tpl_def~\
engine_intake_manifold_temp_tpl_def~vehicle_speed_mph_tpl_def"

append就是你想要的:

append tpl_def(0) \
    "$displacement_tpl_def~$pressure_tpl_def~$vibration_tpl_def~$temperature_tpl_def~" \
    "$load_tpl_def~idling_tpl_def~miles_gallon_tpl_def~engine_temp_tpl_def~" \
    "engine_speed_tpl_def~accelerator_position_tpl_def~vehicle_speed_tpl_def~" \
    "miles_per_gallon_tpl_def~engine_intake_manifold_pressure_tpl_def~" \
    "engine_intake_manifold_temp_tpl_def~vehicle_speed_mph_tpl_def"