Thread: loading muliable table from a single file

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    10

    loading muliable textbox from a single file

    ******sorry i typed table instead of textbox in the title********

    ok im new to this forum so im sorry if i break any rule or that my post are baddly formateed.
    ok here what im trying to do. i have a .txt file containing multiable pieces of data in this format:

    Name "Jack"
    surname "wilson"
    Age"14"
    etc. as well as single lines that assigned type info such as
    unemployed
    employeed
    etc.
    please note this is just a fake templete to show what the file is and how some of the data layed out, its not the way i would have done it, it just the way the current system stores data.
    ok so my problem is that im trying to produce a simple program where it seperates out they lines into text boxes.

    e.g.

    in text box one would have a lable called "Name" and would contain "jack" and in another text box would contain "wilson".

    now im told thazt this can be achieve though sometihng called parsing, which ofcause i nooded to pretend to know what that was, but i don't. so if anyone knows how to achieve the end i wish for could they please tell me or better yet direct me to a bit of example code that i could look at.

    Also if it is possable i need the program to save it. so if i need to do something different to get it into a format im capable to save. please could someone point that out to.

    Plz also note that my problem is not with getting the data or saving it. it is what i do with it oncve i've got it.
    Last edited by linoukus; 06-14-2008 at 04:34 PM.

  2. #2
    Registered User
    Join Date
    Jun 2008
    Posts
    10
    sry for bumping this thread, but alot is riding on this. I have posted on many forum and no-one has replied. I know very sad.

    Is there a reason why no one has replied, e.g. noone understands my question, no one know the answer, i am asking the wrong question, am i asking in the wrong place or completely barking up the wrong tree.

    any respone would be useful even if it to say i don't know.
    I really need an anwser to this or could someone redirectly to a tutoral or an example code that does something simular

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Probably you are not getting responses because you haven't shown any effort on your part (other than posting the question). It is a bit hard to help someone who says he knows nothing...

    Anyway, given strings such as
    name "John"
    unemployed
    you should be able to separate them into a string that runs until the first space (or end of string) and another string that is the part between the quotes (if any).

    std::strings find method helps you to find characters in the input string and substr method helps you extract a substring (once you know where it starts and how long it is).

    To get the strings displayed in the GUI, you probably need to map the first substring to a control (be it a huge hard-coded if-else chain or a map of strings and control handles).
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    you haven't actually specified here what needs to be done!

    you say you need to break up the text in the files and place the strings in text boxes, and then save them.

    if they're in a text file to begin with, they data has already been saved, so it is unclear what you wish to accomplish.

    in your case, the basic process of parsing would go something like this:

    open the file
    read a line
    determine what data is in the line (either by a constant order (e.g. every Nth line is first name) or a data identifier (e.g. Name), and if applicable, identify data substring from identifier and whitespace

    this is extremely general, but it doesn't seem possible to be more specific with the information you provided.



    also, unless you really have to use C++ for this, i'd recommend using a scripting language like PHP or perl.

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    10
    ah ok yes

    i need to use C++ (well C.net) because the program i have created for it, i did in C.net and is a very large program that i don't particulary want to recode in php.

    What i need to do is worki out how to seperate a string, which i load from a text file that look like i said.

    The perpose of the program is look up data, edit it, then save. the problem im have is that i've never done anything with C.net before and im self teaching myself as i go along. and i have been looking for a way to do this, but with out knowing what im looking for im pritty stuck.

    What would be very useful is a tutoral or an example Piece of code which haddle the seperating of the string and if you could point be in the direction i would be helpful.

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    C.net???

    // facepalm

  7. #7
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    Quote Originally Posted by linkolus
    The perpose of the program is look up data, edit it, then save.
    what you really need is a database. that is exactly what they are for...


    there's no single answer on how you do something like this. you may be looking for a shortcut where one simply doesn't exist. you're going to have to analyze the text information yourself by breaking the lines into words and/or characters and implementing the appropriate logic to store each piece of information.

    or use a db, which i highly recommend.

  8. #8
    Registered User
    Join Date
    Jun 2008
    Posts
    10
    i would love to use a db, unforanly the system this is a no go, cause the files i am accessing are create and are used by a current file system my company uses, the perpuse of the program i am creating is to sort of sort sut the current system and allow me to access it remotly etc.

    you're going to have to analyze the text information yourself by breaking the lines into words and/or characters and implementing the appropriate logic to store each piece of information.
    i know this, i was just under teh impresion that i could do this with out a masive If statement, at the very least i would like a way to break up each line into seperate strings, the rest i can sort out myself

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by linoukus View Post
    i know this, i was just under teh impresion that i could do this with out a masive If statement, at the very least i would like a way to break up each line into seperate strings, the rest i can sort out myself
    So read about strchr() and strtok() already.

  10. #10
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    uhhh...whoever is in charge of IT/software at your company deserves to be boiled in oil.

    or at least fired.

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > now im told thazt this can be achieve though sometihng called parsing, which ofcause i nooded to pretend to know what that was
    Mmm - kay...

    > but alot is riding on this
    Such as?

    > cause the files i am accessing are create and are used by a current file system my company uses
    Ah, now it becomes clearer.

    I'm seeing someone who managed to blag a job they're totally incapable of doing, and the company is just about to realise it by giving you this simple assignment. It's bad enough dealing with the free homework crowd, nevermind the free job crowd.

    Fess up, resign from the job you can't do and find something easier in life.
    Or pay half your salary to some eager beaver at www.rentacoder.com
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  12. #12
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    that's rather harsh. he could be an intern trying to get a promotion or permanent position for all you know. i was in that position in college once. tho i wasn't as bad off as linkolus here...

    besides, if someone higher up conceived a company wide system so foul as to use a bunch of text files in place of a database, i really doubt they're savvy enough to peg him as incapable straight off.

  13. #13
    Registered User
    Join Date
    Jun 2008
    Posts
    10
    uhhh...whoever is in charge of IT/software at your company deserves to be boiled in oil.

    or at least fired.
    This is true, only problem is that some tit higher up desided to out source all our IT on a five year contract, which in other words means that i all our system are now 3 years out of date (we are 3 years into contract) and have no been touched or updated since except to get them barlly running again. problem is that the way we do busness has changed so we need to add new thing to the system (which of cause the contractor won't unless paid £££££ which we can afford. So my boss has come to me and said can your sort this out for me and i thought "yeah, why not i have some Coding knowage i should be able to get by" which i would like to point for someone who has not used C.net beofe or even any C langwage, i have produce quite an impressise program that does anything i need i just did not know how to do this one thing, i could not for the life of me work out how or what to look for, So i asked online to which i get this reception.

    I'm seeing someone who managed to blag a job they're totally incapable of doing, and the company is just about to realise it by giving you this simple assignment. It's bad enough dealing with the free homework crowd, nevermind the free job crowd.

    Fess up, resign from the job you can't do and find something easier in life.
    Or pay half your salary to some eager beaver at www.rentacoder.com
    Im sorry i did not realised i would affend by asking for help, your right what an odd thing to do, to need help with something and to come to a form design to help people like me and other solve problem they have. How silly of me. And as for the 'free job crowd' i've have been working here a year and a half and been promoted twice. I do my job very well and get pay acordingly. And yes my spelling is very poor but half the people working in the computer industry are the same.




    So read about strchr() and strtok() already.
    THANK YOU, Now was that so hard, it is all i wanted was to be pointed at the infomation so i could work it out myself.
    thank you Tabstop, I have now got a ruff idea on how to do this and should be fine.


    Just to give you a ruff idea of how bad the Contractors are. The main reason they were hired was to create and maintain at system that would allow us to have people place orders online and to link all our, what was then a compete paper based system into one overall linked system that could be access from anywhere. And at least half of the system they built us is driven by 'Lookup fields'( please note i have blank the formention word, because it is eveil and may offend people who are sensative to baddly made databases).

    Oh and just so you know the guy who agreed to the contract was fired. but not for this mistake. he was fire for racking up £100,000 of debt on the company credit card due to online poker.
    Last edited by linoukus; 06-19-2008 at 12:56 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. need help with .md3 file loading
    By Shadow12345 in forum Game Programming
    Replies: 2
    Last Post: 12-06-2002, 04:06 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM