Announcement

Collapse
No announcement yet.

displaying large amounts of text

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    displaying large amounts of text

    Hi all,

    I have a lot of text that I want to display in a textbox on my form.
    Instead of hardcoding it in, which would be a nightmare, I have typed it in
    a .txt format. Besides readng the file, parsing it and displaying
    it in a multi-line textbox, is there any other ways of doing this, or what
    do you do to display lots of text?


    ------------------
    Henning
    Henning

    #2
    the main question is: do you want to store that long text inside your exe or
    do you want to read it from a file. you mentioned the last possibility yourself, so i
    assume you want to store the text inside your exe.
    when writing a short program, i usually store the helptext in the exe itself. that
    way i have a single executable file.
    an example of this you can find on the source code forum: http://www.powerbasic.com/support/pb...ad.php?t=23072
    it is my project timer.
    i usually use 'binbas' or 'file2asm' to transform a textfile into data statements (binbas)
    or inline assembler statements (file2asm). you can then simply read the text
    into a string and display this into your richedit box or plain text box.
    the 2 mentioned routines are by the hand of fellow pb programmers and can be found
    in these forums.
    hope this helps.
    kind regards
    eddy

    ------------------
    [email protected]

    [this message has been edited by eddy van esch (edited october 02, 2001).]
    Eddy

    Comment


      #3
      Just include it as a resource, much easier for editing purposes.

      I would hate using BinBas everytime I changed the file.

      ------------------
      -Greg
      -Greg
      [email protected]
      MCP,MCSA,MCSE,MCSD

      Comment


        #4
        Greg,

        I like the idea of putting it into a resource file. I've put icons
        in resource files before, but not large amounts of text. What would
        I write in the rc file to separate 5 text-references?

        ------------------
        Henning
        Henning

        Comment


          #5
          Think text in resource files becomes double-byte, that is, twice as big
          when compiled. Usually, easiest and most convinient to use standard way,
          via text file.


          ------------------

          Comment


            #6
            yes, string table text is stored in unicode which doubles the size of the ansi strings you are likely to be storing.

            however, saving it as a "binary resource" would remove this problem.

            the .rc file entry would look like this:
            Code:
            mydata  rcdata  "textfile.txt"
            search the bbs for "rcdata" and you should find some examples on reading the data from the embedded resource file.

            for example: http://www.powerbasic.com/support/pb...ad.php?t=22630


            ------------------
            lance
            powerbasic support
            mailto:[email protected][email protected]</a>
            Lance
            mailto:[email protected]

            Comment


              #7
              Henning;

              Using the RichEdit control works best, since you can load the control
              with RTF (Rich Text Format) text. Use Wordpad to format the text,
              save the file as an RTF file. Read the RTF file from a disk file
              in your app and pass the text to the Rich Edit control.

              If you are using DDT or SDK style code you will need to use the
              EM_STREAMIN message. This message requires creating a function
              call of which you will pass an address to the rich edit control.
              Using this message allows you to load megabytes of RTF (or ascii) text
              into the control. Even on Windows 95, you can load megabytes into
              the rich edit control.


              ------------------


              [This message has been edited by Chris Boss (edited October 02, 2001).]
              Chris Boss
              Computer Workshop
              Developer of "EZGUI"
              http://cwsof.com
              http://twitter.com/EZGUIProGuy

              Comment


                #8
                Thanks Lance,

                I looked at the code, got the text into my .pbr file. Scratching
                my head over retrieving the data from the resource. This sample by
                Semen is kind of getting me on the way, but ...

                I am using the '|' sign as delimiter for my paragraphs. Would it be possible to
                get the whole file into one string and parse it?

                Code:
                DataAddr = LOADRESOURCE(BYVAL 0,BYVAL FINDRESOURCE(BYVAL 0&,_
                           "REGINFO",BYVAL %RT_RCDATA))
                    DIM I AS LONG
                    FOR I=1 TO %DataCount
                        DataItem = @DataAddr[i-1] + DataAddr:MSGBOX @DataItem
                    NEXT


                ------------------
                Henning
                Henning

                Comment


                  #9
                  Thanks Chris!

                  I changed it to a RichText control, parsed the filed the way I waneted
                  and loaded it into my six boxes.

                  btw if someone has a code to retrieve the text from the resource
                  into a string, I'd appreciate it.



                  ------------------
                  Henning
                  Henning

                  Comment


                    #10
                    Code:
                        DIM L1 AS LONG
                        DIM L2 AS LONG
                        DIM SBuffer AS STRING
                        DIM D1 AS DWORD
                        '
                        L1 = FindResource(hInst, BYVAL %ID, BYVAL %RT_RCDATA
                        'If you NAMED your resource, use the name instead of BYVAL %ID:
                        L1 = FindResource(hInst, "MYDATA", BYVAL %RT_RCDATA
                        'If you use an integer identifier, put the numebr in place
                        'of %ID
                        L1 = FindResource(hInst, BYVAL 101, BYVAL %RT_RCDATA)
                        IF L1 = %NULL THEN ERROR 101
                        L2 = LoadResource(hInst, L1)
                        IF L2 = %NULL THEN ERROR 102
                        D1 = LockResource(L2)
                        IF D1 = %NULL THEN ERROR 103
                        SBuffer = PEEK$(D1, 11111)
                        'Replace 11111 with the actual size of the resource (the size of
                        'of the file stored as the resource)
                        'Note that hInst is the Instance of the process owning the
                        'resource. I don't know if this method would work with
                        'LoadLibrary/FreeLibrary
                        'Once you've read the resource into the string variable (in this
                        'case, SBuffer), you may then use it in whichever way you
                        'require for your program
                        'I use this method to create autoextracting, autoinstalling
                        'EXE's to distribute my custom DLL's that my Public Release
                        'programs use  [img]http://www.powerbasic.com/support/forums/smile.gif[/img]
                        'LockResource returns the address of the actual memory
                        'location where the resource is stored
                        'Note that you do NOT have to Unlock the resource in 32-bit
                        'Windows, according to Win32.hlp
                    Hope this helps!

                    Regards,


                    ------------------
                    Clay C. Clear

                    Clay Clear's Software
                    mailto:[email protected][email protected]</A>

                    Comment


                      #11
                      Thanks Clay!



                      ------------------
                      Henning
                      Henning

                      Comment

                      Working...
                      X
                      😀
                      🥰
                      🤢
                      😎
                      😡
                      👍
                      👎