[Haskell]How to read in haskell and solve simple problems

Hello,
I'm an experienced C/C++ programmer and I would like to use Haskell to solve some problems.
But it is hard to me to write a simple way to read input from a file and analyze it, so I ask you how to do this. I didn't find how to do this around google or this forum, that's why I came to here.
Suppose we are given this problem:
"We're analyzing numbers and we want to know which numbers are even. The input consists on a number, N, and then N lines which contain a single integer. You are to say what numbers are even."
INPUT EXAMPLE:
3
1234
5555555
123044390581349287182
OUTPUT EXAMPLE:
yes
no
yes
I wrote the module that returns a string depending on if the number is even or not... But I would like to know how to repeat that function for N numbers. I don't want a superoptimized way or a strange way, I just want a simple and readable one...
In C++ i would do:
for (int i = 0; i < cases; i++)
cin >> number;
cout << analyze(number) << endl; // analyze returns a string
Can you iluminate with your knowledge, archers?
Thank you.

Well, you said that the first line has the number N, followed by N lines. Given your description the program would always test the whole file.
If you have a file with X lines and you'd only like to test N <= X  lines, this should do it:
module Main where
import System.IO
import Control.Applicative
main = do
let test x = if even (read x) then "yes" else "no"
withFile "test" ReadMode $ \handle -> do
nlines <- read <$> hGetLine handle
content <- hGetContents handle
mapM_ ( putStrLn . test )
. take nlines
. lines
$ content

Similar Messages

  • How to read the date and time information of a file by labview

    how to read the date and time information of a file by labview? for example, created time and modified time.
    Solved!
    Go to Solution.

    if you need to know the last modification date of file:-
    "Functions->File I/O->Advanced File Functions->File/Directory Info.vi"
    This vi returns the value of file's last modification date. This is returned as U32 number. To see it in MM/DD/YY format you must create the indicator, right-click on it and select "Format & Precision" item from drop-down menu. Then select "Time and Date" format there.
    Thanks as kudos only

  • I'm having problems with iPhoto and the facebook set-up.  Every time I attempt to do so it says an error has occured and try again later.  I have not seen a solution posted.  Therefore, how does one contact Apple to solve the problem?  I'm new to the worl

    I'm having problems with iPhoto and the facebook set-up.  Every time I attempt to do so it says an error has occured and try again later.  I have not seen a solution posted.  Therefore, how does one contact Apple to solve the problem?  I'm new to the world of iMac but I find it a bit frustrating trying to solve basic issues/problems:(

    For what it's worth, you posted this in 2011, and here in 2014 I am still having this same issue. Over the last two days, I have had to unlock my apple account 8 times. I didn't get any new devices. I haven't initiated a password reset. I didn't forget my password. I set up two factor authentication and have been able to do the unlocking with the key and using a code sent to one of my devices. 
    That all works.
    It's this having to unlock my account every time I go to use any of my devices. And I have many: iMac, iPad, iPad2, iPad mini, iPhone 5s, iPod touch (daughter), and my old iPhone 4 being used as an ipod touch now.  They are all synced, and all was working just fine.
    I have initiated an incident with Apple (again) but I know they are just going to suggest I change my Apple ID. It's a simple one, and one that I am sure others think is theirs. I don't want to change it. I shouldn't have to. Apple should be able to tell me who is trying to use it, or at least from where.
    Thanks for listening,
    Melissa

  • How to read .html file and store values into oracle table  from html file

    Hi all ,
    How to read .html file and store values into oracle table from html file using pl/sql
    Please Help.....

    Hi,
    Kindly find following sample html code ,i want to store every value in different column in database .
    <html><body><p/>
    <div style="position:absolute;top:47px;left:37px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:47px;left:680px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;">  
    </div>
    <div style="position:absolute;top:94px;left:151px;font-family:'Times New Roman';font-size:1pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:1080px;left:115px;font-family:'Times New Roman';font-size:8pt;white-space:nowrap;">4497743
    </div>
    <div style="position:absolute;top:1079px;left:442px;font-family:'Times New Roman';font-size:9pt;white-space:nowrap;"> Miclyn Express Offshore Pre-Quotation Disclosure
    </div>
    <div style="position:absolute;top:1079px;left:680px;font-family:'Times New Roman';font-size:9pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:1079px;left:723px;font-family:'Times New Roman';font-size:9pt;white-space:nowrap;">page 5
    </div>
    <div style="position:absolute;top:1083px;left:151px;font-family:'Times New Roman';font-size:1pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:107px;left:151px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Attachment 2 ¿ indicative statement of 20 largest shareholders </b>
    </div>
    <div style="position:absolute;top:139px;left:262px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Name </b>
    </div>
    <div style="position:absolute;top:131px;left:415px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Number of Shares </b>
    </div>
    <div style="position:absolute;top:147px;left:458px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Held </b>
    </div>
    <div style="position:absolute;top:131px;left:560px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Percentage of </b>
    </div>
    <div style="position:absolute;top:147px;left:567px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>shares held </b>
    </div>
    <div style="position:absolute;top:179px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Macquarie Capital Group Limited 92,378,000
    </div>
    <div style="position:absolute;top:179px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:179px;left:618px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">34.00%r
    </div>
    <div style="position:absolute;top:179px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:212px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">HSBC Custody Nominees (Australia)
    </div>
    <div style="position:absolute;top:227px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Limited
    </div>
    <div style="position:absolute;top:220px;left:464px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">36,458,220
    </div>
    <div style="position:absolute;top:220px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:220px;left:618px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">13.42%
    </div>
    <div style="position:absolute;top:220px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:260px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Ray Rider Limited 27,170,000
    </div>
    <div style="position:absolute;top:260px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:260px;left:618px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">10.00%
    </div>
    <div style="position:absolute;top:260px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:300px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:300px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">7.96%
    </div>
    <div style="position:absolute;top:300px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:333px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">National Australia Bank Custodian
    </div>
    <div style="position:absolute;top:348px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Services
    </div>
    <div style="position:absolute;top:341px;left:464px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">12,866,550
    </div>
    <div style="position:absolute;top:341px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:341px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">4.74%
    </div>
    <div style="position:absolute;top:341px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:381px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Citigroup Nominees Pty Ltd 6,942,541
    </div>
    <div style="position:absolute;top:381px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:381px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">2.56%r
    </div>
    <div style="position:absolute;top:381px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:421px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:421px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">2.14%r
    </div>
    <div style="position:absolute;top:421px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:462px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">UBS Securities Australia Ltd 4,806,760
    </div>
    <div style="position:absolute;top:462px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:462px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1.77%
    </div>
    <div style="position:absolute;top:462px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:494px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Merrill Lynch Equities (Australia)
    </div>
    <div style="position:absolute;top:510px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Limited
    </div>
    <div style="position:absolute;top:502px;left:472px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">4,325,000
    </div>
    <div style="position:absolute;top:502px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:502px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1.59%
    </div>
    <div style="position:absolute;top:502px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:550px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Equities Ltd
    </div>
    <div style="position:absolute;top:542px;left:472px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">4,150,000
    </div>
    <div style="position:absolute;top:542px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:542px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1.53%
    </div>
    <div style="position:absolute;top:542px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:575px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Bond Street Custodians Limited - A/C
    </div>
    <div style="position:absolute;top:590px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Institutional
    </div>
    <div style="position:absolute;top:583px;left:472px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">2,750,000
    </div>
    <div style="position:absolute;top:583px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:583px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1.01%
    </div>
    <div style="position:absolute;top:583px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:623px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Cogent Investment Operations Pty Ltd 2,599,321
    </div>
    <div style="position:absolute;top:623px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:623px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.96%
    </div>
    <div style="position:absolute;top:623px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:663px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Skeet Nominees Pty Ltd 2,276,736
    </div>
    <div style="position:absolute;top:663px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:663px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.84%
    </div>
    <div style="position:absolute;top:663px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:704px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Diederik de Boer 1,917,561
    </div>
    <div style="position:absolute;top:704px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:704px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.71%
    </div>
    <div style="position:absolute;top:704px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:744px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Ecapital Nominees Pty Limited 1,594,736
    </div>
    <div style="position:absolute;top:744px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:744px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.59%
    </div>
    <div style="position:absolute;top:744px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:777px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Neweconomy Com Au Nominees Pty 9
    </div>
    <div style="position:absolute;top:792px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Limited &#60;900 Account&#62;
    </div>
    <div style="position:absolute;top:784px;left:472px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1,594,7360
    </div>
    <div style="position:absolute;top:784px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:784px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.59%
    </div>
    <div style="position:absolute;top:784px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:825px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Sonray Capital Markets Pty Ltd 1,236,842
    </div>
    <div style="position:absolute;top:825px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:825px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.46%
    </div>
    <div style="position:absolute;top:825px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:865px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Argo Investments Limited 1,050,000
    </div>
    <div style="position:absolute;top:865px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:865px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.39%
    </div>
    <div style="position:absolute;top:865px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;"> 
    </div>
    <div style="position:absolute;top:905px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Idameno (No 79) Nominees Pty Limited 724,210</div>
    <div style="position:absolute;top:1103px;">
    </body></html>
    Thanks..........................

  • How to read particular Sector and Block in Mifare 1k through Java?

    Hi Friends..
    Do you know how to read particular Sector and Block in Mifare 1K through Java?..
    I've created the simple application that read data from Mifare 1K, but i've problem when i want to read the other sectors and blocks..
    i tried to read the blocks by using this APDU command :
    FF B0 00 00 10  //read data in Sector 0 and Block 0
    FF B0 00 01 10  //read data in Sector 0 and Block 1
    FF B0 00 02 10  //read data in Sector 0 and Block 2
    FF B0 00 03 10  //read data in Sector 0 and Block 1How to read the other sectors and blocks?..
    I've tried to read data in Sector 1 and Block 5, so i tried to send this APDU command : FF B0 01 05 10, but i got this error : *6986*
    Actually, it doesn't matter if i use MifareWnd, but i want to create my own application that Read/Write From/into Mifare 1K..
    Please help me regarding this..
    Thanks in advance..
    Edited by: Leonardo_Carreira on Mar 31, 2010 2:47 AM
    Edited by: Leonardo_Carreira on Mar 31, 2010 2:50 AM

    Hi Sidd,
    You should check out the Example Finder under Hardware Input and Output»IMAQ»Signal Input and Output for examples of triggering in framegrabbers.
    Stephen Meserve
    National Instruments

  • How to disable Setting button in Tools - Options - Advanced - Network..i've read an article that solved this problem..but thats problem contains web adress that couldn't be opened..any other solution??? thanks before best regard

    How to disable Setting button in Tools - Options - Advanced - Network..i've read an article that solved this problem..but thats problem contains web adress that couldn't be opened..any other solution???
    thanks before
    best regard
    -ariansyah-

    You can disable or remove that button, but that won't prevent users from making the changes on the about:config page directly.<br />
    You can lock the related network.proxy prefs if you do not want users to change the connection settings.
    See:
    *http://kb.mozillazine.org/Locking_preferences
    * http://kb.mozillazine.org/network.proxy.type
    * http://kb.mozillazine.org/network.proxy.%28protocol%29
    * http://kb.mozillazine.org/network.proxy.%28protocol%29_port

  • My AppStore can not download app. He said need to fill in credit card. But I got no credit card. And how I fill in? Please solve the problem. Thank you.

    My AppStore can not download app. He said need to fill in credit card. But I got no credit card. And how I fill in? Please solve the problem. Thank you.
    <Email Edited by Host>

    Hi Steve,
    If you don't have a credit card for the billing information you may be able to use a gift card or another form of payment.
    Please check out this article for details.
    Why can’t I select None when I edit my Apple ID payment information? - Apple Support
    Best,
    Nubz

  • How to read flat file and convert to xml throught OSB

    Hi ,
    Can somebody help how to read flat file and convert to xml in OSB.
    appreciate ur help.
    Thanks & Regards ,
    Siva K Divi

    if you're using the oepe with osb plugin (will be installed when you install the osb locally) and then in your osb project > rightmouseclick > new > MFL.
    that's it
    maybe you're trying to create it within an oepe installation which doesnt have the osb plugin ?

  • After downloading the mac os x 10.6.8 I can't open safari. It first told me that I could not run it with Safari 5.1 so I downloaded safari 6 because I had read that that would solve the problem. However I am still getting an error message. HELP!!

    After downloading the mac os x 10.6.8 I can't open safari. It first told me that I could not run it with Safari 5.1 so I downloaded safari 6 because I had read that that would solve the problem. However I am still getting an error message. HELP!!

    I see this on Apple's support page:
    Available for: OS X Lion v10.7.5, OS X Lion Server v10.7.5, OS X Mountain Lion v10.8 and v10.8.1

  • How do you contact Apple to solve a problem?

    How do you contact Apple to solve a problem?

    Most people would start by clicking the "Contact Us" link at the bottom of the website.

  • When printing in Excel It is always want to use the acrobat X pro trial, which the trial is expired. I do not want to use acrobat X pro trial anymore. How can I reset it and use simple acrobat to print my PDF document?

    When printing in Excel It is always want to use the acrobat X pro trial, which the trial is expired. I do not want to use acrobat X pro trial anymore. How can I reset it and use simple acrobat to print my PDF document?

    Hi screen name,
    Adobe PDF printer gets installed when you install Acrobat 10 Pro.
    To use this printer you need to purchase Acrobat. Once the trial period is over you cannot use the printer to create pdf files.
    An alternative way for you is to utilize Microsoft's own inbuilt pdf engine.
    You can simply open the file and select 'Save as' and in the type list select 'pdf'
    Please refer : http://office.microsoft.com/en-in/excel-help/save-as-pdf-HA010354239.aspx
    Regards,
    Rave

  • How to read XML file and write into another XML file

    Hi all, I am new to JAVAXML.
    My problem is I have to read one XML file and take some Nodes from that and write these nodes into another XML file...
    I solved, how to read XML file
    But I don't know how to Write nodes into another XML.
    Can anyone help in this???
    Thanks in advance..

    This was answered a bit ago. There was a thread called "XML Mergine" that started on Sept 14th. It has a lot of information about what it takes to copy nodes from one XML Document object into another.
    Dave Patterson

  • How to Read All Discussions and Replies

    Hi,
    I have to read all discussions and replies of a sharepoint discussion board using object model.
    Any help is greatly appreciated.
    Thanks,
    Tushar

    Finally I was able to solve this puzzle. Thought of sharing for people still having this issue:
    1) Take instance of your site collection and web:
    SPSite currentSite = SPContext.Current.Site;
    SPWeb currentRootWeb = currentSite.RootWeb;
    2) Suppose I have the name of discussion list - "MyDiscussionList". Get GUID of this list:
    Guid myDiscussionListGUID = Guid.NewGuid();
    foreach (SPList list in currentRootWeb.Lists)
          if (list.BaseTemplate.ToString() == "DiscussionBoard" && list.Title == "MyDiscussionList")
                myDiscussionListGUID = list.ID; // Read GUID of Discussion List
                break;
    Tips:
    a) list.ItemCount will return all discussions and their replies
    b) list.Items.Count will return only replies
    3) Get your list:
    SPList myDiscussionList = currentRootWeb.Lists.GetList(myDiscussionListGUID, false);
    4) Create a new Discussion
    SPListItem newItem = SPUtility.CreateNewDiscussion(myDiscussionList.Items, "New Message using code");
    newItem["Body"] = "My new message content using code";
    newItem.Update();
    5) How to read all discussions:
    foreach (SPListItem folder in myDiscussionList.Folders)
         Response.Write("Folder Name: " + folder.Name + "<BR>");
         Response.Write("Folder ID: " + folder.ID + "<BR>");
         Response.Write("Attachments Count: " + folder.Attachments.Count + "<BR>"); // Returns attachment count
         // Code to read attachment URL.
         for (int i = 0; i < folder.Attachments.Count; i++)
                Response.Write("Attachment Url " + folder.Attachments.UrlPrefix + folder.Attachments + "<BR>");
         // Read body of attachment
         Response.Write("Body: " + folder.Fields["Body"].GetFieldValueAsText(folder["Body"]) + "<BR>"); 
    6) If you want to delete a discussion
    SPListItem listItemParentToDelete = null;
    foreach (SPListItem folder in myDiscussionList.Folders)
          listItemParentToDelete = folder;
    if (listItemParentToDelete != null)
        listItemParentToDelete.Delete();
    7) Loop through all discussion replies:
    foreach (SPListItem listItem in myDiscussionList.Items)
         Response.Write("Item DisplayName: " + listItem.DisplayName + "<BR>"); // Returns Title of Discussion
         Response.Write("List ID: " + listItem.ID + "<BR>");
         Response.Write("List Folder ID: " + listItem.Fields["Parent Folder Id"].GetFieldValueAsText(listItem["Parent Folder Id"]).ToString() + "<BR>"); // Returns ID of Parent Discussion
         Response.Write("Body: " + listItem.Fields["Body"].GetFieldValueAsText(listItem["Body"]) + "<BR>");
         // Create Parent List Item
         int parentListID = Convert.ToInt32(listItem.Fields["Parent Folder Id"].GetFieldValueAsText(listItem["Parent Folder Id"]));
         SPListItem parentListItem = lvContentItemsDiscussionsList.GetItemById(parentListID);
         Response.Write("Parent List Item Name: " + parentListItem.Name + "<BR>");
         // Code to Reply to a Discussion Message
         SPListItem reply = SPUtility.CreateNewDiscussionReply(parentListItem);
         reply["Body"] = "<div class=ExternalClass89C47CD7892B4279A8F42A65DD63AE3A><div> </div> <div>Reply to the new message<br><br> <hr> <b>From: </b>Admin<br><b>Posted: </b>Friday, July 20, 2007 4:01 AM<br><b>Subject: </b>New message<br><br> <div class=ExternalClass3D04672E599B486F9ECB76C138494708> <div>My new message content</div></div></div></div>";
         reply["TrimmedBody"] = "<div class=ExternalClass677134B4EA284660B1B236824800345C><div> </div> <div>Reply to the new message<br></div></div>";
         reply.Update();
        // Code to delete a discussion reply
        listItemToDelete = listItem;
    8) Code to delete a discussion reply:
    SPListItem listItemToDelete = null;
    foreach (SPListItem listItem in myDiscussionList.Items)
        listItemToDelete = listItem;
    // Code to delete a discussion reply
    if (listItemToDelete != null)
        listItemToDelete.Delete();
    Note: You need to allow unsafe updates in order to do any operation on SharePoint list directly.
    currentRootWeb.AllowUnsafeUpdates = true;
    Hope this help!
    Thanks!

  • How to read xml file and place it into an internal table...

    hello all,
    can any one help me in - how to read xml data file (placed in application server) and placing the same into an internal table (remove the xml tags or say fetching the xml data without xml tags).

    Hi Murashali,
    use this.
    TYPES: BEGIN OF day,
    name TYPE string,
    work(1) TYPE c,
    END OF day.
    DATA: BEGIN OF week,
    day1 TYPE day,
    day2 TYPE day,
    day3 TYPE day,
    day4 TYPE day,
    day5 TYPE day,
    day6 TYPE day,
    day7 TYPE day,
    END OF week.
    DATA xml_string TYPE string.
    DATA result LIKE week.
    week-day1-name = 'Monday'. week-day1-work = 'X'.
    week-day2-name = 'Tuesday'. week-day2-work = 'X'.
    week-day3-name = 'Wednesday'. week-day3-work = 'X'.
    week-day4-name = 'Thursday'. week-day4-work = 'X'.
    week-day5-name = 'Friday'. week-day5-work = 'X'.
    week-day6-name = 'Saturday'. week-day6-work = ' '.
    week-day7-name = 'Sunday'. week-day7-work = ' '.
    CALL TRANSFORMATION ...
    SOURCE root = week
    RESULT XML xml_string.
    CALL TRANSFORMATION ...
    SOURCE XML xml_string
    RESULT root = result.
    Regards,
    Vijay

  • How to read XML file and update the data in MS CRM 2011?

    Hi Folks,
    Can anyone please help me finding some references to read XML files and push the data to MS CRM 2011 preferably by using a console application.
    Please let me know if any ways of handling it in simple ways.
    Thanks,
    Sri

    HI,
    How to read XML file:
    https://social.msdn.microsoft.com/Forums/en-US/5dd7261b-86c4-4ca8-ba87-95196ef3ba50/need-to-display-xml-file-in-textboxes-edit-the-data-and-save-the-new-xml-file?forum=csharpgeneral
    How to work with CRM:
    ClientCredentials credentials = new ClientCredentials();
    credentials.Windows.ClientCredential = new System.Net.NetworkCredential("USER", "Password", "Domain");
    Uri uri = new Uri("http://server/Organization/XRMServices/2011/Organization.svc");
    OrganizationServiceProxy proxy = new OrganizationServiceProxy(uri, null, credentials, null);
    proxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
    IOrganizationService service = (IOrganizationService)proxy;
    //using "service" you can create, update and retrieve entities.
    More information here about service functions:
    https://msdn.microsoft.com/en-us/library/gg328198.aspx

Maybe you are looking for

  • BEx: V 3.5: Structures: Duplication of data when structure is used.

    Good day I have searched SDN already, but could not find an anser for my issue. I have created a Structure in columns which include the characteristic "Model Key" as follows: BUS = Model Keys (BUS and CVLA) FUSO = Model Keys (MCTR and MFUS) In the qu

  • DOMException while accessing child SOAPElement's

    I've implemented a servlet that receives SOAP messages and processes them. When I try to use SOAPElement's getChildElements(Name name) method, calling i.next() on the Iterator throws a DOMException. Here's the code: public static String testGetValue(

  • How to AS2 to AS3..?

    I have a code in AS2 that loads the bg image on my html page, from swf. I've turned in AS3, but not working. Here is the code: AS2 getURL ("javascript:document.body.background=\"new.jpg\";;void(0)"); AS3 import flash.net.*; navigateToURL(new URLReque

  • Audigy 2 + 7.1 Probl

    Hey, Just got a new custom PC, and put my audigy 2 into it aswell, plugged it in, set all the software up, but, when i go to test speakers, where she goes (front left, front right, etc etc) the goes threw, and when its up to the side ones, no sound c

  • Defaulting the colum from the previous page table column values.

    Hi, I have two seeded pages. In First page it contains one table and 4 columns namely SNo, Competency, Previous Rating, Main Appraiser Rating and in second page it contains one table and 3 columns namely SNo, Competency, New Appraisal Rating. My Requ