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 39397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:51:30+00:00 2026-05-10T14:51:30+00:00

Has anyone written an ‘UnFormat’ routine for Delphi? What I’m imagining is the inverse

  • 0

Has anyone written an ‘UnFormat’ routine for Delphi?

What I’m imagining is the inverse of SysUtils.Format and looks something like this

UnFormat(‘a number %n and another %n’,[float1, float2]);

So you could unpack a string into a series of variables using format strings.

I’ve looked at the ‘Format’ routine in SysUtils, but I’ve never used assembly so it is meaningless to me.

  • 1 1 Answer
  • 3 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. 2026-05-10T14:51:31+00:00Added an answer on May 10, 2026 at 2:51 pm

    This is called scanf in C, I’ve made a Delphi look-a-like for this :

    function ScanFormat(const Input, Format: string; Args: array of Pointer): Integer; var   InputOffset: Integer;   FormatOffset: Integer;   InputChar: Char;   FormatChar: Char;    function _GetInputChar: Char;   begin     if InputOffset <= Length(Input) then     begin       Result := Input[InputOffset];       Inc(InputOffset);     end     else       Result := #0;   end;    function _PeekFormatChar: Char;   begin     if FormatOffset <= Length(Format) then       Result := Format[FormatOffset]     else       Result := #0;   end;    function _GetFormatChar: Char;   begin     Result := _PeekFormatChar;     if Result <> #0 then       Inc(FormatOffset);   end;    function _ScanInputString(const Arg: Pointer = nil): string;   var     EndChar: Char;   begin     Result := '';     EndChar := _PeekFormatChar;     InputChar := _GetInputChar;     while (InputChar > ' ')       and (InputChar <> EndChar) do     begin       Result := Result + InputChar;       InputChar := _GetInputChar;     end;      if InputChar <> #0 then       Dec(InputOffset);      if Assigned(Arg) then       PString(Arg)^ := Result;   end;    function _ScanInputInteger(const Arg: Pointer): Boolean;   var     Value: string;   begin     Value := _ScanInputString;     Result := TryStrToInt(Value, {out} PInteger(Arg)^);   end;    procedure _Raise;   begin     raise EConvertError.CreateFmt('Unknown ScanFormat character : '%s'!', [FormatChar]);   end;  begin   Result := 0;   InputOffset := 1;   FormatOffset := 1;   FormatChar := _GetFormatChar;   while FormatChar <> #0 do   begin     if FormatChar <> '%' then     begin       InputChar := _GetInputChar;       if (InputChar = #0)       or (FormatChar <> InputChar) then         Exit;     end     else     begin       FormatChar := _GetFormatChar;       case FormatChar of         '%':           if _GetInputChar <> '%' then             Exit;         's':           begin             _ScanInputString(Args[Result]);             Inc(Result);           end;         'd', 'u':           begin             if not _ScanInputInteger(Args[Result]) then               Exit;              Inc(Result);           end;       else         _Raise;       end;     end;      FormatChar := _GetFormatChar;   end; end; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone written some interesting or cool Linq extension methods they would like to
Is there some standard way or has anyone written something that allows you to
Has anyone written something similar to SQL::Abstract for Sybase::DBLib ? in particular, I'm interested
Has anyone written a macro that will remove and sort your usings in an
Has anyone used both Joone and Encog in production applications? Is there something you
Has anyone written XACML Implementations other than the Sun XACML Implementation and XEngine? Who
Has anyone come across a script / cl app written in any language that
Has anyone written either a long or short program in COW that demonstrates what
Has anyone written a Fast Algorithm that generates a LARGE dummy file in PHP,
Has anyone written a fast Fourier transform extension for R that modifies R's native

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.