Thread: BorlandC proj

  1. #61
    Registered User
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    28
    ok seems like I have to forget about the part related to display,as its gonna take lots of time apparently!
    Guys I also have another problem! in this prg the user has 2 options, either to create a table and put in the data to play with too by himself, or he can just load the data from an input file(the first line of which contains the row & col of the table) so using the first line the table is created and data put in!
    for the sec option(load) I'm having problems with how to set up the input file to fill out the table in its special manner! (jus so u know my tables' first row and col related to zero indecies is unused and that might cuz problems in loading I guess). and if the file format does not matter so then how should I load from a file in a way to put in the data in a tablular form for filling in the cells of the table!?

  2. #62
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by mary18 View Post
    ok seems like I have to forget about the part related to display,as its gonna take lots of time apparently!
    Guys I also have another problem! in this prg the user has 2 options, either to create a table and put in the data to play with too by himself, or he can just load the data from an input file(the first line of which contains the row & col of the table) so using the first line the table is created and data put in!
    for the sec option(load) I'm having problems with how to set up the input file to fill out the table in its special manner! (jus so u know my tables' first row and col related to zero indecies is unused and that might cuz problems in loading I guess). and if the file format does not matter so then how should I load from a file in a way to put in the data in a tablular form for filling in the cells of the table!?

    Any format you find clear and simple to use is fine, maybe:

    A20 44.36
    So cell number, followed by a single space, followed by the value to put into the cell.

    A is the column, 20 is the row, value is 44.36

    After reading the data in from the file, it's just: Array[row][col] = value;

    Remember to keep the row as the first dimension of your array, even though the row is the second part of the data from the file.

    The data doesn't need to be in a "tabular form", it just needs to be in the right element of the array that corresponds to the cell number. Your display puts the array in the right form. The array is just a plain old 2D array, albeit with base 26.

  3. #63
    Registered User
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    28

    -

    Hi,
    I got it but in a different way!
    I have the file in such a way that the data for each row is put in a single line in the file and each value on that line is put inside braces! so each time I do fgets for getting each line in the file and then the data are put in the table(only data, no braces)! it worked. now guess what, this phase of my proj is over too! I got it working!
    now the last phase, is to make our excel functions dynamic. u know in the prev phase, for setting a value to a cell by assigning a math expression to it, it would only get the formula, calc the result and store it in that cell, so what the expression was, is completely forgotten unless the user rentered it!and there's no sign of it in the output file(used to save the table). but now we want it to save the from of the expressions as well so like if we had A1= 3 + 4 * B45 and B45 was 4, we'd see the value of 19 for A1, but if B45 was changed to 0, we wanna see 3 for A1 now! in the prev phase , A1 wouldn't changed with a change in B45.
    now we're told as a suggestion to let each cell have the list of all other cells to which its related. so in the struct we had for each cell, we're told to add the list of all cells to which that cell is sensitive so if the cell's content changes, all the cells to which it was sensitive, have to be calculated again!and that recalculation, is done using the formula saved before! for the list, since we don't know how long it is we're told to implement it using linked list!
    now I'm a bit confused about how to save the formulas set to a cell! cuz the way my save part worked was jus to get the content of each cell and store it in a file! now since the formula is not put in a cell of table and only the cells to which its sensitive are included in the cell struct, how do I get the formula to save in the file!
    this thing sounds somehow unclear to me! I can't get how it works!

  4. #64
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I think the best way is to save the formula within the cell, but ignore the "relations to other cells" - instead, when you load the file, rebuild the linked lists of relations at that point. Just treat all cells as if they had just been typed in, if you see what I mean.

    I think this is the question you are asking - if you actually are asking about something else, please feel free to ask chastise me and clarify what you want to know.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #65
    Registered User
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    28
    thanx 4 replying!
    ok right, sounds like a good idea to have the formula as a part of the cell struct!
    and then when loading the file and building the lniked list, the list is also set to be a part of struct as well, right?! so like in addition to what we had in cell struct, we need two more: the formula and the list!?
    u know what I confused about now is that, before in my prg, I had put several cases for user to choose from , like load from file or create a table , set a cell.... so in the case of "load from file" in my input file there were only digits and so after loading the table with values in the file, I'd use other options for setting a cell, deleting ... playing with the values and cells and then saving the new table of value in my output file!
    but now would the orignal input file still contain digits only and then later when we load it and play with it, we'd assign formulas to some cells and then that formula is gonna be saved in the output file instead of the value that was assigned to it previously!?
    so I mean the original input file is the same, but the output file would be completely different from what we had in the prev phase, right?!?

  6. #66
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, you do need several things in the cell structure - however, in the external file (that you load from), you only need a single string. This string is then converted according to the same rules as when you enter a new cell directly. This in turn means that you have to "know" how to distinguish a formula from a number or a string [assuming you support strings, and Excel also supports for example dates as content in cells]. How does this work right now?

    Note: If you are storing strings, it may make sense to put them in quotes or some other separator - and you may need to further "hide" any quotes within the string, e.g. if you store strings with double quotes, "Like this", then you will have to make sure that double quotes are "escaped" in the string, e.g:
    A string with "string in it"
    would become:
    "A string with \"string in it\""

    You don't have to use backslash, but it's pretty commonly used for this purpose - and you obviously also need to quote backslashes too.

    [Or just deny the user the quote character - if you use something rather unusual, like ~ or ^ as a quote, it's unlikely that anyone will worry about it]

    --
    Mats
    Last edited by matsp; 01-23-2008 at 07:27 AM.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #67
    Registered User
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    28

    down

    Hi,
    I'm still stock on the last phase!
    Mats, I am supposed to do it jus the way I explained it to u! each cell havin the list of all cells to which it is related!
    I have a snippet of my prog for which I'm getting an error and can't seem to know why! (I'm having problems using linked list)
    u know I had a struct for each cell that now looks like this:
    Code:
    struct cell{
       float content;
       int isValid;
       char *formula;
       relative *list;
    };
    the last variable is the list of relative cells and its of this type(its a node of the list):

    Code:
    struct relative{
       relative *next;
       Address adrs;   
    };
    and again the last variable of this one is of this type:

    Code:
    struct Address{
       int row
       int col;
    };
    so when I get a formula for say A1(first of all I track to see where A1 is, so I get row=1 and col=1 for A1), like A1= 2* B3 +1 - B4...etc, I'm going thru everything after equal sign and then whenever I see a cell address like B3 in here, I follow the same process of getting the row and col num of B3 and store them in two variables like in here crow4=3, and ccol4=2 for B3.
    and then I want this info to be part of a new node of the list of relatives, so I do this:

    Code:
    table[row][col].list= (relative*)malloc(sizeof(relative));
    to create a new node of type relative for that specific cell being A1 here in order to store info about its first relative, B3. then:

    Code:
    table[row][col].list.adrs.row= crow4;
    table[row][col].list.adrs.col= ccol4;
    but I'm getting an error when compiling: "Structure required on the left side of . or .* "

    plz help me out!

  8. #68
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    table[row][col].list->adrs.row= crow4;
    table[row][col].list->adrs.col= ccol4;
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #69
    Registered User
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    28

    Thumbs up Thnx

    Heyyy guys!
    now u go like: "oahhh not her againnn! with her stupid Q's!" no don get me wrong this time! no more Q's on C! I'm done!
    just wanted to say ThanK YoU to all of u guys that were of gr8 help to me in order to handle my proj! its over and I finally ended up with a mark of 90 out of 100 for the proj! I couldn't beleive that I finally did it, and that I did it this good! without u guys I couldn't go thru it! now I feel like how lucky I was to find this forum and be a member of it!

    thanx alot
    Bestest wishes...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fullscreen .exe window in Borlandc
    By mihaio07 in forum C Programming
    Replies: 3
    Last Post: 01-29-2008, 12:57 PM
  2. export vc++ proj to dev c++
    By jay_uccs in forum C++ Programming
    Replies: 1
    Last Post: 06-26-2005, 07:43 AM
  3. Need Help on creating a Proj on Dev C++
    By djxtremor in forum C++ Programming
    Replies: 2
    Last Post: 11-19-2002, 08:24 PM
  4. Simple problem for you guys - school proj
    By ryancsutton in forum C++ Programming
    Replies: 7
    Last Post: 10-01-2002, 03:06 PM