Error executing code: CommaIo object not initialized.
Straightforward stuff...
inputFile = new CommaIo(_fileName, #io_read);
info(strFmt('Status: %1', inputFile.status()));
The code blows up on the info() statement.
inputFile is defined in classDeclaration as type CommaIo.
_fileName is defined as a string.
_fileName does contain a correct, fully-qualified file name.
It doesn't matter where the file is located.
It is a text file.
There are not access security issues.
It does conform to CSV layouts.
Why?
Havnt got an AX here but isnt CommaIO abstract? Try using AsciiIO.
i am pretty sure the file causes this error.
you need to use doublebackslash in order to get a backslash in your string
ie.
doesnt work
str _filename = "c:\mytext.txt";
works fine
str _filename = "c:\\mytext.txt";
i suggest you take a deep look at _filename.
Regards
--
Mathias Füßler
my blog: http://starside.eu
"Peter Laursen" wrote:
AsciiIo also blows up. I've been using CommaIo all along and have plenty of
other class modules using CommaIo just fine. I have looked at working classes
comparing methods back and forth but cannot find anything being done in a
non-standard way. I suspect this is one of those minor gotcha's having to do
with the stack or something along those lines. (I have already tried moving
objects around in classDeclaration just to see if it matters.)
FWIW, this is AX 3.0 SP 3.
"Mathias" wrote:
> Hi ACO,
>
> i am pretty sure the file causes this error.
>
> you need to use doublebackslash in order to get a backslash in your string
>
> ie.
> doesnt work
> str _filename = "c:\mytext.txt";
>
> works fine
> str _filename = "c:\\mytext.txt";
>
> i suggest you take a deep look at _filename.
Thanks. I am very aware of the requirement for escaped backslashes in
strings. Whether I hardcode the qualified file name (as in your second
illustration) or obtain it through a dialog (using
dialog.addField(typeId(FileNameOpen), "File name")) I get the same results.
Here's one for your blog.
"CommaIo object not initialized" was indeed file-related but in a more broad
sense.
The code was correct. The file path and name were correct. Backslashes were
escaped. The calls, the setup, everything was correct, except...
When a new Class is created the RunOn property is set to "Called from" by
default. Changing that to "Client" fixes the problem.
</sigh>
Thought everybody would like to know.
I have been searching for this for about 2 days!
Thanks a million!
This did the trick......