Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Basic 使用打印时出现HP基本异常_Basic_Openvms_Vms - Fatal编程技术网

Basic 使用打印时出现HP基本异常

Basic 使用打印时出现HP基本异常,basic,openvms,vms,Basic,Openvms,Vms,据我了解,以下声明: print using "<0>#,##", 1234 这是有道理的;前导零(其中没有)和五个字符可用于我们要输出的五个字符。我理解的另一个说法是: print using "<0>#####,#######", "12345678"L 同样,考虑到我对格式化字符的理解,这也是有意义的;14个字符可用于数字、逗号和前导零 我不明白的是如何: print using "<0>####,#######", "12345678"L 肯定是

据我了解,以下声明:

print using "<0>#,##", 1234
这是有道理的;前导零(其中没有)和五个字符可用于我们要输出的五个字符。我理解的另一个说法是:

print using "<0>#####,#######", "12345678"L
同样,考虑到我对格式化字符的理解,这也是有意义的;14个字符可用于数字、逗号和前导零

我不明白的是如何:

print using "<0>####,#######", "12345678"L
肯定是前导零太多了?当然应该是:

0,012,345,678
我可以看到,有时在指定的长度上加上前导零,否则输出将以前导逗号开头,如本例所示:

print using "<0>###,#######", "12345678"L

尽管似乎没有预留足够的空间。但是前面的例子是Basic中的一个bug,还是我在这里遗漏了什么?

看起来像是bug。当和数千个分隔符一起玩时,它会增加一个领先零的奖励。 这应该算作一个位置

它在Basic 1.3(OpenVMS 8.3)和OpenVMS 8.4上为我复制了1.7-000。 我使用了较小的测试值,以避免与“长整数的十位数精度”基本参考手册的最大整数大小产生混淆/交互

顺便说一句。。正确使用“nnn”L。这将优先于任何(暗示的)转换讨论。 我会将逗号移动到####序列的末尾或开头,以避免暗示特定的位置

作为一种(但很难看的)解决方法,您可以使用FORMAT$(val,FORMAT string)。 它也有同样的问题,但程序将进行更改以调整结果

$ cre tmp.bas
 1      OPTION TYPE = EXPLICIT, SIZE = INTEGER LONG, CONSTANT TYPE = INTEGER
        print using "<0>###,", 1234
        print using "<0>###,", 123
        print using "<0>###,", 12
        print using "<0>###", 1234
        print using "<0>###", 123
        print using "<0>###", 12
 Exit
$ bas tmp
$ link tmp
$ run tmp
1,234
00,123
00,012
1234
0123
0012
$cre tmp.bas
1选项类型=显式,大小=整数长度,常量类型=整数
使用“####,”,1234打印
使用“###,”,123打印
使用“####,”,12打印
使用“####”和1234打印
使用“####”打印,123
使用“####”打印,12
出口
$bas tmp
$link tmp
$run tmp
1,234
00,123
00,012
1234
0123
0012

基本编译器/RTL版本?BASIC/LIST=TT:TT:…END…^Z.anal/image/select=ident=image sys$library:dec$basrtlThanks确认为bug!我还注意到,有时它无法添加前导零。例如“#########,”,1234生成“000001234”(这与在格式字符串中添加另一个#时得到的输出相同)。
0,012,345,678
print using "<0>###,#######", "12345678"L
0,012,345,678
$ cre tmp.bas
 1      OPTION TYPE = EXPLICIT, SIZE = INTEGER LONG, CONSTANT TYPE = INTEGER
        print using "<0>###,", 1234
        print using "<0>###,", 123
        print using "<0>###,", 12
        print using "<0>###", 1234
        print using "<0>###", 123
        print using "<0>###", 12
 Exit
$ bas tmp
$ link tmp
$ run tmp
1,234
00,123
00,012
1234
0123
0012