devxlogo

Filling a Structure Automatically

Filling a Structure Automatically

Question:
After a structure is defined witha “TYPE” declaration, do you know of a way to directly fillthe structure with data, rather than individually assigingthe elements, or reading from a file? I haven’t seen anyway in either the manuals, or in 4 different after marketreference books that I have.

Answer:
Note: This answer came from the person who asked the question.

I used the code:

        TYPE StructType                ‘/* setup stucture of type char */                a AS STRING * 1                b AS STRING * 1                c AS STRING * 1                d AS STRING * 1        END TYPE        DIM Structure as StructType        ‘/* find the address of the first element */        ptrData& = VARPTR(Structure)        ‘/* then, if I know the structure elements size, */        ‘/*         I can POKE data into them */        Test$=”1234″        ‘/* place the ASCII representation of each char into structure */        for i% = 1 to len(Structure)                POKE i% + ptrStructure& – 1, ASC(MID$(Test$,i%,1))        NEXT        ‘/* display the elements */        PRINT CHR$(Structure.a)        PRINT CHR$(Structure.b)        PRINT CHR$(Structure.c)        PRINT CHR$(Structure.d)

See also  Monetize TikTok For Your Business
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist