Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6754781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:19:18+00:00 2026-05-26T13:19:18+00:00

I’m writing a small tool to do some manipulation of SWF files, using Delphi

  • 0

I’m writing a small tool to do some manipulation of SWF files, using Delphi XE2. So far, I’m simply following the SWF specification, and now I’ve hit a small problem in implementing a data structure to represent shapes.

SWF shapes contain a number of shape records. Shape records may be edge records or non-edge records, and each of those two types have two additional subtypes.

Specifically, on page 135 of the specification, the two non-edge record types are described; EndShapeRecord and StyleChangeRecord. In the SWF file, the way to differentiate between these is to check if all five flag bits (after TypeFlag) are 0; if they are, it’s an EndShapeRecord, otherwise it’s a StyleChangeRecord.

To help me process the shape records later on, I would like to unify edge and non-edge records into a single record type, using a variant record. Distinguishing between the different kinds of records is easy enough; a nested variant record allows me to easily to this the edge records apart, and for the non-edge records, I can declare the 5 flags from the StyleChangeRecord and write a function IsEndRecord.

However, in the interest of making my source code reflect the specification as closely as possible, I’d like to go one step further. The presence of the other fields in a StyleChangeRecord are predicated on the values of these 5 flags, so I would like to be able to declare 5 variant records, one per flag, which contain the fields added by each flag. (I realize this will not affect the memory usage in any way, but that’s not the point.)

Unfortunately, Delphi doesn’t seem to allow more than one variant part per “level”, and attempting to define these 5 variant parts at the same level just throws a ton of syntax errors.

TShapeRecord = record
  case EdgeRecord: Boolean of
    False: (
      case StateMoveTo: Boolean of
        True: (
          MoveBits: Byte;
          MoveDeltaX: Int32;
          MoveDeltaY: Int32;
        );
      case StateLineStyle: Boolean of // << Errors start here
        True: (LineStyle: UInt16);
      //Additional flags
    );
    //Fields for edge records
end;

In slightly simpler terms, the goal is to be able to formulate a record like so:

TNonEdgeRecord = record
    case StateMoveTo: Boolean of
      True: (
        MoveBits: Byte;
        MoveDeltaX: Int32;
        MoveDeltaY: Int32;
      );
    case StateLineStyle: Boolean of
      True: (LineStyle: UInt16);
end;

…without removing the variant parts of the record, and without nesting them (since nesting would imply an incorrect relation from a syntactical point of view).

Is there some other way I can declare multiple (non-nested) variant parts in a record, or should I just go back to not using variant records for the inner part?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:19:19+00:00Added an answer on May 26, 2026 at 1:19 pm

    No. The Borland branch of Pascal only allows variant parts at the end of a record.

    Nesting is the only way.

    For some interesting examples and observations, see this article by Rudy Velthuis:

    http://rvelthuis.de/articles/articles-convert.html (search for the “union” part)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.