Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.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
Arrays 未存储awk中的数组元素时出现问题_Arrays_Awk - Fatal编程技术网

Arrays 未存储awk中的数组元素时出现问题

Arrays 未存储awk中的数组元素时出现问题,arrays,awk,Arrays,Awk,我一直在使用awk处理每小时的天气数据,存储了10个阵列,其中包含多达8784个数据元素。如果数组不完整,即在8250等处停止,则在执行“END”命令后,我用数组的最后一个可用值填充剩余的数组元素。然而,当我打印出完整的数组时,我得到的是0的填充值。这是什么原因造成的??awk的数组大小是否有限制,从而阻止它填充数组?下面是awk程序的一个片段。在这两个print语句中,第一次填充数组元素,但第二次为空 感谢您的帮助,因为这个问题阻碍了我的工作 黄乔 END{ if (lastpresstime

我一直在使用awk处理每小时的天气数据,存储了10个阵列,其中包含多达8784个数据元素。如果数组不完整,即在8250等处停止,则在执行“END”命令后,我用数组的最后一个可用值填充剩余的数组元素。然而,当我打印出完整的数组时,我得到的是0的填充值。这是什么原因造成的??awk的数组大小是否有限制,从而阻止它填充数组?下面是awk程序的一个片段。在这两个print语句中,第一次填充数组元素,但第二次为空

感谢您的帮助,因为这个问题阻碍了我的工作

黄乔

END{
if (lastpresstime < tothrs)
   {
   diffhr = tothrs - lastpresstime
   for (i=lastpresstime+1;i<=tothrs+1;i++)
      {
      xpressinter[i]=diffhr
      xpressrecords[i]=diffhr
      xipress[i]=lastpress
      xpressflag[i]="R"
      printf("PRS xipress[%4d] =%6.1f\n",i,xipress[i]) > "ncdcfm3.prs"
      printf(" xipress[%4d] =%6.1f%1s\n",i,xipress[i],xpressflag[i])
      }
   for (i=1;i<=tothrs+1;i++) printf("PRS xipress[%4d] =%6.1f\n",i,xipress[i]) 
   }
结束{
如果(最后按时间<总小时)
{
diffhr=tothrs-上次按时间
对于(i=lastpresstime+1;i“ncdcfm3.prs”
printf(“xipress[%4d]=%6.1f%1s\n”,i,xipress[i],xpressflag[i])
}

对于(i=1;i由于0是未知/未使用的数值变量的默认值,我想问您是否确定在结束块中使用的变量名称中没有键入错误?

我没有代表来编辑您的帖子,但以下是格式化代码:

END {
    if (lastpresstime < tothrs) {
        diffhr = tothrs - lastpresstime
        for (i=lastpresstime+1;i<=tothrs+1;i++) {
            xpressinter[i]=diffhr
            xpressrecords[i]=diffhr
            xipress[i]=lastpress
            xpressflag[i]="R"
            printf("PRS xipress[%4d] =%6.1f\n",i,xipress[i]) > "ncdcfm3.prs"
            printf(" xipress[%4d] =%6.1f%1s\n",i,xipress[i],xpressflag[i])
        }
        for (i=1;i<=tothrs+1;i++)
            printf("PRS xipress[%4d] =%6.1f\n",i,xipress[i])
    }
}
结束{
如果(最后按时间<总小时){
diffhr=tothrs-上次按时间
对于(i=lastpresstime+1;i“ncdcfm3.prs”
printf(“xipress[%4d]=%6.1f%1s\n”,i,xipress[i],xpressflag[i])
}

对于(i=1;i)有3个printf语句。哪一个是问题所在?请使用标记重新格式化您的问题。