[NXC][ArrayLen] Inconcistencies
Posted: 15 Jul 2011, 02:08
Compiler bug. The following code:
Displays:
Specifications:
Side note: Removing
Code: Select all
string InsertSpaces(string a, string b, unsigned long len = 16)
{
char chSpaces[];
unsigned int chSpaces_len = len - (strlen(a) + strlen(b));
ArrayInit(chSpaces, 0x20, chSpaces_len);
return(a + ByteArrayToStr(chSpaces) + b);
}
void DisplayMenu(string title, string &list[], unsigned long pos = 0)
{
TextOut(0, LCD_LINE1, title, DRAW_OPT_INVERT);
}
void DisplayFileList(unsigned long pos, ListFilesType &lftFiles)
{
unsigned int FileCount = ArrayLen(lftFiles.FileList);
string fl[];
ArrayBuild(fl, lftFiles.FileList);
DisplayMenu(InsertSpaces("File Count:", NumToStr(FileCount), 16), fl, pos);
}
void SelectFile(ListFilesType &lftFiles)
{
unsigned int FileCount = ArrayLen(lftFiles.FileList);
ClearScreen();
DisplayFileList(0, lftFiles);
TextOut(0, 0, InsertSpaces("File Count:", NumToStr(FileCount), 16));
}
task main()
{
ListFilesType lftFiles;
lftFiles.Pattern = "*.*";
SysListFiles(lftFiles);
SelectFile(lftFiles);
Wait(5000);
}
Code: Select all
File Count: 10
File Count: 0
- Next Byte Codes Compiler version 1.2 (1.2.1.5, built Thu Jul 7 07:08:23 CDT 2011)
- Optimization Level 2
nbc -sm- -ER=5 -Z2 -EF
Side note: Removing
pos
seems to get rid of the bug...