I am having trouble as a C beginning trying to compile the code below using XCode. I am new to C and have always programmed in pascal in the past. This is to be a plugin for 4th Dimension. Most of the hooks were generated with "4D Plugin Wizard". It generates the C code for the plugin to be used by XCode. I think most of my errors are simple declaration problems or problems with the C language. I am getting the following errors:
error: parse error before "int" error: parse error before "char" error: parse error before '+' token error: subscripted value is neither array nor pointer
The code follows:
/* -------------------------------------------------------------------------------- # # 4DPlugin.c # source generated by 4D Plugin Wizard # Project : new Project # author : subaru # 1/29/10 # # This plugin should recieve two variable from the main 4D program. # # The first variable from 4D -------------- # One will be an array of length 54 composed of # characters (0-9 and A-Z). Each element represents a schedule day. Each character in the element represents a # 10 minute block of time in the schedule. When the character is 0 (zero) there is nothing scheduled for that time. # The difficulty of the the 10 minute time block increases as the ascii value of the character that represents it # increases in value from 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,..... etc. # # The second variable from 4D -------------- # This variable will be an integer value that represents the difficulty of the new appointment. # This value should be subtracted from the ascii value of the character that represents each 10 minute # time block. The harder the new appointment the smaller the value of the variable for the difficulty. # -------------------------------------------------------------------------------- */
// -------------------------------- schedule Plugin -------------------------------
void s_Convert_Array( PA_PluginParameters params ) {
PA_Variable DayArray; //an array of characters of length 54 from 4d short Difficulty; //an interger denoting difficulty of an appointment PA_Variable FinishedArray; // completed array returned to 4D char returnValue[256];
DayArray = PA_GetVariableParameter( params, 1 ); Difficulty = PA_GetShortParameter( params, 2 );
// --- write the code of s_Convert_Array here...
{ int counter = 0; int array_size = sizeof(DayArray); int Day_Difficulty_AsciiValue; //used to hold one character int slot_number; char slot_char;
while (counter < array_size) //array_size should be the number of elements of array DayArray { counter++;
int counter2 = 0; while (counter2 < 55) //stepping through each character of DayArray { counter2++;
//ERROR BELOW (error before "int") Day_Difficulty_AsciiValue =int(DayArray[counter2]); // function to convert a char in array to ascii value if (Day_Difficulty_AsciiValue>=65) // is character a letter slot_number = Day_Difficulty_AsciiValue-7-48; else //character is a number slot_number = Day_Difficulty_AsciiValue-48;
slot_number = slot_number - Day_Difficulty_AsciiValue;
if(slot_number<0) slot_number = 0;
// convert the number to the characters 0-1,A-Z // 48 is the number of ascii values before the numbers begin // 7 is the numbere of unused ascii values between the numbers and capital letters
if(slot_number>=10) //number will be converted to a character //ERROR BELOW (error before "char") (error before '+' token) slot_char = char(slot_number+48+7); else // this will be a number slot_char = char(slot_number+48);
//ERROR BELOW (subscripted value is neither array nor pointer) FinishedArray[counter2] = slot_char; // store the character back into the original array to be passed to 4D }
}
}
PA_SetVariableParameter( params, 3, FinishedArray, 1 ); PA_ReturnString( params, returnValue ); }
|