Everything I say refers to C/C++ not to AFL directly keep that in mind!
>So is the problem that the switch() statement does not support arrays?
Based on the error message you get as well as the fact that you claim AFL is similar to C then yes, that is the culprit! C/C++ allows only integer types "to be switched". (Well, that's not the whole truth - if you have a class(type) for which an conversion to an integer type is defined then you could switch that one too)
The only question is, what kind of array is the function returning (array of WHAT type) and at which location inside the array is the value you're interested in. For the fun of it I'm taking a wild guess and choose the very first location inside the array. Access to individual array values are done with the index operator[]. In C/C++ Indexing starts with 0. So in your case:
varDayOfWeek[0] (probably) represents the first element in the array
If the Day of the week is stored at that location and the array type is an integer type you're set and done.
switch( varDayOfWeek[0] )
{
//whatever...
}
If for instance a character array is returned things get more complicated.
Look at the following code:
int MyInt = 1;
char MyChar = '1';
What values are stored at the memory locations where MyInt and MyChar reside ? For MyInt the value is the binary representation of 1. And for MyChar ? No, not 1 - but 49! That's the ordinal value of the character literal '1' in the ASCII table!
So first you would have to cast (programming jargon for converting) the char to - let's say - int.
C-style: (int) varDayOfWeek[0]
C++-style: static_cast<int>(varDayOfWeek[0])
Now let's take a look at the ASCII table. The digits start at location 48 (for 0) and rise to location 57 (for 9). Now in order to map the char literal '1' to the value 1 (what you would need!) how do you procede ? Well easy enough, simply subtract the ordinal value of the char literal '0' !!!! So should a char array be returned:
switch( ((int)varDayOfWeek[0] - 48) )
{
//whatever...
}
would do the trick!
Use the debug output window or whatever (debugger?) of Amibroker to take a look at your variable varDayOfWeek in order to get an idea what type and/or where the value you're interested is located (should varDayOfWeek[0] not hit bullseye)
br,
moneyclip
PS: Before you start trading invest in your education and buy yourself an introduction level book for C/C++ You're in urgent need of one
>So is the problem that the switch() statement does not support arrays?
Based on the error message you get as well as the fact that you claim AFL is similar to C then yes, that is the culprit! C/C++ allows only integer types "to be switched". (Well, that's not the whole truth - if you have a class(type) for which an conversion to an integer type is defined then you could switch that one too)
The only question is, what kind of array is the function returning (array of WHAT type) and at which location inside the array is the value you're interested in. For the fun of it I'm taking a wild guess and choose the very first location inside the array. Access to individual array values are done with the index operator[]. In C/C++ Indexing starts with 0. So in your case:
varDayOfWeek[0] (probably) represents the first element in the array
If the Day of the week is stored at that location and the array type is an integer type you're set and done.
switch( varDayOfWeek[0] )
{
//whatever...
}
If for instance a character array is returned things get more complicated.
Look at the following code:
int MyInt = 1;
char MyChar = '1';
What values are stored at the memory locations where MyInt and MyChar reside ? For MyInt the value is the binary representation of 1. And for MyChar ? No, not 1 - but 49! That's the ordinal value of the character literal '1' in the ASCII table!
So first you would have to cast (programming jargon for converting) the char to - let's say - int.
C-style: (int) varDayOfWeek[0]
C++-style: static_cast<int>(varDayOfWeek[0])
Now let's take a look at the ASCII table. The digits start at location 48 (for 0) and rise to location 57 (for 9). Now in order to map the char literal '1' to the value 1 (what you would need!) how do you procede ? Well easy enough, simply subtract the ordinal value of the char literal '0' !!!! So should a char array be returned:
switch( ((int)varDayOfWeek[0] - 48) )
{
//whatever...
}
would do the trick!
Use the debug output window or whatever (debugger?) of Amibroker to take a look at your variable varDayOfWeek in order to get an idea what type and/or where the value you're interested is located (should varDayOfWeek[0] not hit bullseye)
br,
moneyclip
PS: Before you start trading invest in your education and buy yourself an introduction level book for C/C++ You're in urgent need of one