Announcement

Collapse
No announcement yet.

How to include a very long string in a program??

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

  • How to include a very long string in a program??

    I need to embed some very long strings that are svg images. I hate to do the "data data" _ thing. Obviously I could pull the data in from a file as a single string without all the extra "" stuff. I was wondering if a RESOURCE might have a way of dealing with this.

    Code:
    <path id="VeroLock" class="cls-1" d="M21.325,41.91L10.814,17.079V6.678c0-2.08-1-3.25-3.575-3.25S3.664,4.6,3.664,6.678v10.27a6.133,6.133,0,0,0,.429,2.535L17.75,51.14C18.465,52.765,19.109,54,21.325,54s2.86-1.235,3.575-2.86L38.557,19.484a6.131,6.131,0,0,0,.429-2.535V6.678c0-2.08-1-3.25-3.575-3.25s-3.575,1.17-3.575,3.25v10.4ZM84.888,54c2,0,4.719-.39,4.719-3.12,0-2.665-2.431-3.12-4.719-3.12H70.159c-2.288,0-3.647-.26-4.576-1.17L63.866,44.9a2.958,2.958,0,0,1-1-1.82V41H84.888c4.076,0,4.719-1.04,4.719-4.615V31.379c0-3.445-.429-5.85-3.575-8.125l-2.789-2.015c-2.646-1.95-4.219-2.275-7.579-2.275H69.372c-2.789,0-4.362.065-7.579,2.6l-2.431,1.885C56.5,25.659,56,27.609,56,30.924V42.95c0,3.38.786,4.81,3.5,7.02l2.932,2.34C64.581,54,65.725,54,68.586,54h16.3ZM62.865,30.339a2.769,2.769,0,0,1,1.43-2.86l2.36-1.56a5.982,5.982,0,0,1,3.5-.715H75.95a5.25,5.25,0,0,1,3.289.78l2.646,2.08c0.93,0.78.858,1.755,0.858,2.925v3.77H62.865v-4.42ZM107.48,49.71c0,2.145.5,4.29,3.432,4.29s3.432-2.145,3.432-4.29v-15.8l9.582-7.215a5.556,5.556,0,0,1,3.432-1.5h2c1.644,0,3.289,0,4.147,1.105a3.8,3.8,0,0,1,.715,2.73c0,2.015,1,3.835,3.5,3.835,2.931,0,3.36-2.21,3.36-4.355a8.7,8.7,0,0,0-3.074-7.085,9.548,9.548,0,0,0-6.722-2.47h-5.5c-2.145,0-4.147,1.235-6.078,2.665l-5.363,4.03V23.124c0-2.08-.715-4.16-3.432-4.16-3.146,0-3.432,2.34-3.432,4.615V49.71Zm51.479-7.345c0,4.1,1.144,5.655,4.719,8.385s5,3.25,9.367,3.25h5.434c4.362,0,5.792-.52,9.367-3.25s4.719-4.29,4.719-8.385V30.6c0-4.16-.929-5.59-4.361-8.125-3.361-2.535-4.934-3.51-9.725-3.51h-5.434c-4.791,0-6.364.975-9.724,3.51-3.432,2.535-4.362,3.965-4.362,8.125V42.365ZM165.823,30.6c0-1.3.5-2.145,2.5-3.705a6.592,6.592,0,0,1,4.719-1.69h5.434a6.592,6.592,0,0,1,4.719,1.69c2,1.56,2.5,2.405,2.5,3.705V42.365c0,1.3-.5,2.145-2.5,3.705a6.593,6.593,0,0,1-4.719,1.69h-5.434a6.593,6.593,0,0,1-4.719-1.69c-2-1.56-2.5-2.405-2.5-3.705V30.6ZM216.73,47.5V6.678c0-2.08-1-3.25-3.575-3.25s-3.575,1.17-3.575,3.25V54h31.747c1.859,0,3.575-.91,3.575-3.25s-1.716-3.25-3.575-3.25h-24.6Zm45.187-5.135c0,4.1,1.144,5.655,4.719,8.385S271.641,54,276,54h5.434c4.362,0,5.792-.52,9.367-3.25s4.719-4.29,4.719-8.385V30.6c0-4.16-.929-5.59-4.361-8.125-3.361-2.535-4.934-3.51-9.725-3.51H276c-4.791,0-6.364.975-9.724,3.51-3.432,2.535-4.362,3.965-4.362,8.125V42.365ZM268.781,30.6c0-1.3.5-2.145,2.5-3.705A6.592,6.592,0,0,1,276,25.2h5.434a6.592,6.592,0,0,1,4.719,1.69c2,1.56,2.5,2.405,2.5,3.705V42.365c0,1.3-.5,2.145-2.5,3.705a6.593,6.593,0,0,1-4.719,1.69H276a6.593,6.593,0,0,1-4.719-1.69c-2-1.56-2.5-2.405-2.5-3.705V30.6ZM313.4,39.5c0,3.835.787,5.72,4.076,8.19l5.076,3.835c3.218,2.405,4.863,2.47,8.867,2.47h10.868c2.288,0,4.719-.455,4.719-3.12,0-2.73-2.717-3.12-4.719-3.12H330.2a6.8,6.8,0,0,1-3.932-1.56l-4.148-3.185c-1.072-.78-1.859-1.43-1.859-2.665V32.614c0-1.235.787-1.885,1.859-2.665l4.148-3.185A6.8,6.8,0,0,1,330.2,25.2h12.084c2,0,4.719-.39,4.719-3.12,0-2.665-2.431-3.12-4.719-3.12H331.415c-4,0-5.649.065-8.867,2.47l-5.076,3.835c-3.289,2.47-4.076,4.355-4.076,8.19V39.5Zm58.343-5.98V10.383c0-2.145-.5-4.29-3.432-4.29s-3.432,2.145-3.432,4.29V49.71c0,2.145.5,4.29,3.432,4.29s3.432-2.145,3.432-4.29V41.78l2.86-2.34L391.832,52.5c1,0.715,1.859,1.5,3.217,1.5a3.3,3.3,0,0,0,3.432-3.185c0-1.625-1.144-2.34-2.431-3.315L379.891,35.279l13.3-10.01c1.216-.91,2.288-1.625,2.288-3.12a3.3,3.3,0,0,0-3.432-3.185c-1.645,0-3.361,1.56-4.576,2.535Z"/>

  • #2
    Yes, as a resource.

    Assuming "svg" is for "scalable vector grapgics", where is conversion to raster graphics done? If in the program you're writing, store as a string in svg format. Else, convert to bitmap and store as a DIB string resource.

    Changing images? Store as resources in multiple DLLs.

    Cheers,
    Dale

    Comment


    • #3
      Thanks Dale.
      The SVG is streamed to a browser from the program.

      I guess the RESOURCE needs to be defined in a file that was not created with the PB editor...??? To get past the 256 line length??

      Comment


      • #4
        > a file that was not created with the PB editor

        That's old school.

        The modern #RESOURCE metastatement allows you to embed copies of external files, of any type, directly into your program, without using a separate "resource file" or data-type statements. Check out...

        #RESOURCE RCDATA

        ...which allows you to embed anything you want. IIRC, RC = "Raw Character Data". It is not limited to ".DAT" files, as the help implies.
        "Not my circus, not my monkeys."

        Comment


        • #5
          Originally posted by David Clarke View Post
          Thanks Dale.
          The SVG is streamed to a browser from the program.

          I guess the RESOURCE needs to be defined in a file that was not created with the PB editor...??? To get past the 256 line length??
          Yep, Just create it using a good editor such as Notepad++. Then specify the created file as:
          Code:
          #RESOURCE RCDATA, svg1, "SVGImage1.svg"
          and access it in your program with
          Code:
          strSVG= RESOURCE$(RCDATA."svg1")
          (Don't try to store it as a STRING resource, that implies WSTRING and is length and ID type restricted)

          Comment


          • #6
            > create it using a good editor such as Notepad

            I'll offer a clarification:

            If the file doesn't already exist, create it using... etc. There's no requirement to use an external editor.
            "Not my circus, not my monkeys."

            Comment


            • #7
              Stuart is correct. For PBWin 10 and PBCC 6 #RESOURCE STRING is limited to 1 to 127 wide characters containing no nuls. Older versions precompiled resources and did things differently.

              So what I said in post 2 is condional upon PB version.

              Cheers,
              Dale

              Comment


              • #8
                Thanks All! Great answers.

                Comment


                • #9
                  Originally posted by Eric Pearson View Post
                  > create it using a good editor such as Notepad

                  I'll offer a clarification:

                  If the file doesn't already exist, create it using... etc. There's no requirement to use an external editor.
                  There is if you want to create or modify an SVG string that is more than 256 characters since the PBEditor is limited to that line length.

                  Comment


                  • #10
                    I wasn't trying to correct you, I thought the OP implied that a file already exists but I probably over-analyzed.
                    "Not my circus, not my monkeys."

                    Comment


                    • #11
                      It can be stored as ASMDATA if you have a way to convert the data to DB format. The RC format that Stuart described works fine if you want to load it as a file.
                      hutch at movsd dot com
                      The MASM Forum

                      www.masm32.com

                      Comment


                      • #12
                        Here is a toy that will do exactly what you need, take any external file and convert it into a DB notation that is written back as a normal basic string. It can handle any file size data and it is accessible as a normal basic string. This is the output format.
                        Code:
                        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                        
                          ' File K:\basic_tools\bin2dbex\blackgrad.bmp opened at 310 bytes
                        
                        FUNCTION blackgrad_bmp() as STRING
                        
                            #REGISTER NONE
                        
                            LOCAL pdst as DWORD
                        
                            dst$ = space$(310)
                            pdst = StrPtr(dst$)
                        
                            ! cld
                            ! mov esi, OFFSET bindata
                            ! mov edi, pdst
                            ! mov ecx, 310
                            ! rep movsb
                        
                            FUNCTION = dst$
                            Exit FUNCTION
                        
                          bindata:
                           ! db 66,77,14,1,0,0,0,0,0,0,54,0,0,0,40,0
                           ! db 0,0,1,0,0,0,64,0,0,0,1,0,24,0,0,0
                           ! db 0,0,0,1,0,0,195,14,0,0,195,14,0,0,0,0
                           ! db 0,0,0,0,0,0,0,1,3,0,237,236,242,0,232,232
                           ! db 232,0,232,234,235,0,224,228,230,0,223,222,221,0,223,216
                           ! db 217,0,213,213,213,0,209,209,209,0,209,207,206,0,204,207
                           ! db 209,0,197,201,204,0,196,197,197,0,192,191,197,0,186,190
                           ! db 192,0,185,185,186,0,180,183,180,0,177,178,178,0,173,176
                           ! db 176,0,168,170,174,0,166,165,165,0,166,159,160,0,159,162
                           ! db 163,0,155,154,153,0,155,152,151,0,149,149,146,0,143,142
                           ! db 146,0,141,138,144,0,132,137,140,0,135,133,132,0,130,130
                           ! db 131,0,122,124,128,0,120,120,121,0,115,119,116,0,112,113
                           ! db 114,0,111,113,108,0,102,107,110,0,105,103,106,0,97,97
                           ! db 101,0,95,96,93,0,89,90,92,0,88,86,91,0,81,83
                           ! db 84,0,81,79,79,0,72,79,77,0,73,71,76,0,70,64
                           ! db 70,0,65,67,62,0,59,63,65,0,51,57,56,0,49,52
                           ! db 57,0,51,45,47,0,44,43,48,0,37,40,45,0,35,37
                           ! db 38,0,34,33,37,0,32,26,28,0,21,22,24,0,17,18
                           ! db 24,0,19,21,16,0,13,17,19,0,5,11,15,0,4,6
                           ! db 8,0,0,0,7,0
                        
                        END FUNCTION
                        
                        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                        Attached Files
                        hutch at movsd dot com
                        The MASM Forum

                        www.masm32.com

                        Comment


                        • #13
                          removed
                          Last edited by Dean Gwilliam; 22 Feb 2018, 06:51 AM.

                          Comment


                          • #14
                            Originally posted by Steve Hutchesson View Post
                            Here is a toy that will do exactly what you need, take any external file and convert it into a DB notation that is written back as a normal basic string. It can handle any file size data and it is accessible as a normal basic string. This is the output format.
                            Code:
                            ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                            
                            ' File K:\basic_tools\bin2dbex\blackgrad.bmp opened at 310 bytes
                            
                            FUNCTION blackgrad_bmp() as STRING
                            
                            #REGISTER NONE
                            
                            LOCAL pdst as DWORD
                            
                            dst$ = space$(310)
                            pdst = StrPtr(dst$)
                            
                            ! cld
                            ! mov esi, OFFSET bindata
                            ! mov edi, pdst
                            ! mov ecx, 310
                            ! rep movsb
                            
                            FUNCTION = dst$
                            Exit FUNCTION
                            
                            bindata:
                            ! db 66,77,14,1,0,0,0,0,0,0,54,0,0,0,40,0
                            ! db 0,0,1,0,0,0,64,0,0,0,1,0,24,0,0,0
                            ! db 0,0,0,1,0,0,195,14,0,0,195,14,0,0,0,0
                            ! db 0,0,0,0,0,0,0,1,3,0,237,236,242,0,232,232
                            ! db 232,0,232,234,235,0,224,228,230,0,223,222,221,0,223,216
                            ! db 217,0,213,213,213,0,209,209,209,0,209,207,206,0,204,207
                            ! db 209,0,197,201,204,0,196,197,197,0,192,191,197,0,186,190
                            ! db 192,0,185,185,186,0,180,183,180,0,177,178,178,0,173,176
                            ! db 176,0,168,170,174,0,166,165,165,0,166,159,160,0,159,162
                            ! db 163,0,155,154,153,0,155,152,151,0,149,149,146,0,143,142
                            ! db 146,0,141,138,144,0,132,137,140,0,135,133,132,0,130,130
                            ! db 131,0,122,124,128,0,120,120,121,0,115,119,116,0,112,113
                            ! db 114,0,111,113,108,0,102,107,110,0,105,103,106,0,97,97
                            ! db 101,0,95,96,93,0,89,90,92,0,88,86,91,0,81,83
                            ! db 84,0,81,79,79,0,72,79,77,0,73,71,76,0,70,64
                            ! db 70,0,65,67,62,0,59,63,65,0,51,57,56,0,49,52
                            ! db 57,0,51,45,47,0,44,43,48,0,37,40,45,0,35,37
                            ! db 38,0,34,33,37,0,32,26,28,0,21,22,24,0,17,18
                            ! db 24,0,19,21,16,0,13,17,19,0,5,11,15,0,4,6
                            ! db 8,0,0,0,7,0
                            
                            END FUNCTION
                            
                            ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                            What does that do that:
                            Code:
                             #RESOURCE RCDATA, blackgrad,"K:\basic_tools\bin2dbex\blackgrad.bmp"
                            DIM blackgrd_bmp as STRING
                            blackgrd_bmp = RESOURCE$(RCDATA,"blackgrad")
                            doesn't do much more simply?



                            Comment


                            • #15
                              Stuart,

                              You are right but mine is simpler and faster to use as it includes the data in the basic source file. Now unrelated, I may have confused a capacity with one of the assemblers I use but from memory there was a technique to directly include binary files in PB without using an RC file.
                              hutch at movsd dot com
                              The MASM Forum

                              www.masm32.com

                              Comment


                              • #16
                                Probably not much use to PB programmers and certainly not supported by the #RESURCE statement... you can have multiple physical lines to represent a long string in a *.RC resource scrpt file as demo'd here ===> User-Defined Resource Demo January 26 2003


                                Oops, that demo has no multiline resources. Let me go get one from my product files...

                                ... Ok, here's one:


                                Code:
                                // pppsdemov3.rc
                                //
                                // 10.01.04 1.0.0  Original
                                // 11.01.04 1.0.1  Corrected some typos in richtext and reworded one comment here (database search)
                                // 11.08.04 1.0.2  Changed claims summary report to version which shows "ALLOWED" instead of "COVD CHG"
                                // 06.09.05 2.0.0  Demo for version 3.0
                                // 12.03.07 2.1.0  Demo for version 3.2 very few changes needed
                                
                                #include "resource.h"
                                
                                #define COPYRIGHT_SYMBOL "\251"
                                #define REGISTERED_SYMBOL "\256"
                                #define TRADEMARK_SYMBOL  "\153"
                                
                                ......
                                
                                #define crlf                  0x0a0d      //  inverted because stored as WORD
                                
                                ....
                                
                                //MAIN REMITTANCE PROCESSING SCREEN
                                scr_main      SLIDE       zc_remitcenter_main.bin
                                scr_main      COMMENT
                                BEGIN
                                  "This is the main PPPS remittance processing screen. Either 'Open by File Name' or 'Open by Payer Name' ",
                                  "may be used o select the name of the payer's remittance file to be processed.",
                                  "As that remittance file is opened, the user is ",
                                  "presented with this summary showing remittance advice documents found in that file.",
                                  crlf,
                                  "On this and all other screens of the PPPS, the user may select the 'datasource', which is ",
                                  "the destination for remittance information storage or source for reports and inquires;",
                                  " as well as direct that print report output be sent either directly ",
                                  "to a named printer or to the What-You-See-Is-What-You-Get print previewer."
                                END
                                ...

                                (Actual file is 306 lines but they don't show anything of interest here.)


                                The separate sections of the long string (of text) are delimited by the trailing commas while the actual text is quoted. When this is loaded (Lockresource()) it comes out as one single text string.

                                MCM
                                Michael Mattias
                                Tal Systems (retired)
                                Port Washington WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  While the other suggestions are about various techniques, I'm thinking you might also want to ensure that the program is able to access as much memory as possible...


                                  Code:
                                  #OPTION LARGEMEM32
                                  -John

                                  Comment

                                  Working...
                                  X