I read the posting guidelines for this forum and I hope my question is a good one. I am looking for help using and understanding AFL code for AmiBroker. I know about the Yahoo forum but it is not as interactive as I would like. Any AFL programmers here that are willing to work with me? Thanks,
I would say this is a bad question. Your topic is useless and you didn't say what your problem was. You basically put a job/personal ad
Did you read the manual? Did you try some examples? What is your problem exactly? Do you know how to program?
I want to enhance the Title section of my charts by inserting the day of the week in front of the date: Friday, 12/30/2011. The DayOfWeek() returns a number. So I need to convert the number to text that says what day it is. Here is the code I have so far: for( n = 0; n < 10; n++ ) { printf("Current n = %f\n", n ); varDayOfWeek = DayOfWeek(); switch(varDayOfWeek) { case 0: varDayOnChart == "Sunday"; printf("Day of week is ") + varDayOnChart + "\n"; break; case 1: varDayOnChart == "Monday"; printf("Day of week is ") + varDayOnChart + "\n"; break; case 2: varDayOnChart == "Tuesday"; printf("Day of week is ") + varDayOnChart + "\n"; break; case 3: varDayOnChart == "Wednesday"; printf("Day of week is ") + varDayOnChart + "\n"; break; case 4: varDayOnChart == "Thursday"; printf("Day of week is ") + varDayOnChart + "\n"; break; } The error occurs on the last line. The "}" is highlighted and the error message is : Syntax error, unexpected send. Is there semicolon missing at end of the previous line?"
Thank you rosy2 for your help. I inserted the closing brace and this is what I get. Error 6. Condition in IF, WHILE, FOR statements has to be... (See attached)
knowing absolutely nothing about afl i still decided to take a look at your code (attachment). i do know my share of c/c++ however and since afl looks so familiar.... highlighted is the first switch statement, so the code breaks obviously here. that means the switch statement is not correct. that implies something is not right with varDayOfWeek. varDayOfWeek is assigned DayOfWeek() So what does DayOfWeek() return ? Let's take a look at the hp of amibroker (see attachment). Well, that might explain the error message...... br moneyclip
Thank you moneyclip. I don't know C but I am hearing from people that AFL and C are similar. I appricate you taking the time to look at this and help me out. Okay, so DayOfWeek() returns an Array. I am just learning about arrays (AFL is kind of forcing that). I have assigned DayOfWeek() to varDayOfWeek Then I use varDayOfWeek in the switch() statement: switch(varDayOfWeek) So is the problem that the switch() statement does not support arrays? Here is what the user's guide says: -------------------------------------------------- switch Statement The switch and case statements help control complex conditional and branching operations. The switch statement transfers control to a statement within its body. Syntax: switch ( expression ) { case constant-expression1 : statement; case constant-expression2 : statement; ... case constant-expressionN : statement; default : statement; } ----------------------------------------------------- If it says it accepts an expression does that mean it won't accept an array? Here is the code again: varDayOfWeek = DayOfWeek(); switch(varDayOfWeek) { case 0: // The error # 6 occurs on this line varDayOnChart == "Sunday"; printf("Day of week is ") + varDayOnChart + "\n"; break; case 1: varDayOnChart == "Monday"; printf("Day of week is ") + varDayOnChart + "\n"; break; case 2: varDayOnChart == "Tuesday"; printf("Day of week is ") + varDayOnChart + "\n"; break; case 3: varDayOnChart == "Wednesday"; printf("Day of week is ") + varDayOnChart + "\n"; break; case 4: varDayOnChart == "Thursday"; printf("Day of week is ") + varDayOnChart + "\n"; break; } A # 6 error occurs on the line that says case 0 Here is what it says for error # 6: Condition in IF, WHILE, FOR statements has to be Numeric or Boolean type. You can not use array here, please use [] (array subscript operator) to access array elements. It looks like the returned value from DayOfWeek() needs to be converted from an array in order to use it with the switch statement. Need a work around...
rosy2: Are you trying to sell me something? The site you have referred me to twice is a third party programming vendor. What's up?