📄 dim.c
字号:
#include <CsAgb.h>
#include <rbasic.h>
#include <variable.h>
#include <cal.h>
#include <rb_string.h>
void rb_dim(char *exp)
{
char str[str_max_len];
char indx[str_max_len];
u8 i=0,strp=0,flag=0,type=0;
double index;
u8 count;
while (exp[i]==' ') i++;
while (exp[i]!='\0')
{
while(exp[i]!='[' && exp[i]!='\0')
{
str[strp]=exp[i];
i++;
strp++;
}
if (strp==0||exp[i]=='\0')
{
rb_error=6;
return;
}
str[strp]='\0';
if (str[strp-1]=='#') type=1;
else type=0;
i++;
strp=0;
while (exp[i]!=']' && exp[i]!='\0')
{
indx[strp]=exp[i];
i++;
strp++;
}
if (strp==0 || exp[i]=='\0')
{
rb_error=6;
return;
}
indx[strp]='\0';
index=rb_cal(indx);
if (rb_error) return;
if (index<1 || index>v_max_dim_count)
{
rb_error=25;
return;
}
if (type) rb_int_dim_register(str,index);
else rb_float_dim_register(str,index);
if (rb_error) return;
i++;
while (exp[i]==' ') i++;
if (exp[i]=='=')//有初始化数据
{
i++;
count=1;
if (exp[i]=='\0')
{
rb_error=6;
return;
}
while(exp[i]==' ') i++;
if (exp[i]!='{' || exp[i+1]=='\0')
{
rb_error=6;
return;
}
i++;
while (exp[i]==' ') i++;
strp=0;
while (exp[i]!='}' && exp[i]!='\0')
{
if (!is_number(exp[i]))
{
indx[strp]='\0';
strp=0;
while (exp[i]==' ') i++;
if (exp[i]!=',')
{
rb_error=6;
return;
}
if (type) rb_give_int_dim(str,rb_cal(indx),count);
else rb_give_float_dim(str,rb_cal(indx),count);
if (rb_error) return;
if (exp[i]==',') i++;
while (exp[i]==' ') i++;
count++;
}
else
{
indx[strp]=exp[i];
i++;
strp++;
}
}
indx[strp]='\0';
if (type) rb_give_int_dim(str,rb_cal(indx),count);
else rb_give_float_dim(str,rb_cal(indx),count);
if (rb_error) return;
i++;
}
while (exp[i]==' ') i++;
if (exp[i]!=',' && exp[i]!='\0')
{
rb_error=6;
return;
}
if (exp[i]==',') i++;
while (exp[i]==' ') i++;
strp=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -