Re: StrPas question

From: Skybuck Flying (nospam_at_hotmail.com)
Date: 12/21/04


Date: Tue, 21 Dec 2004 00:46:55 +0100

Actually now that I think about this, this could be seen as a bug ;)

I told delphi to copy "Hello" into an array and I did not tell delphi to
clean the rest of the array :)

Ouch.

"Skybuck Flying" <nospam@hotmail.com> wrote in message news:...
> Well you made it seem like delphi automatically adds a #0 to a string like
> that...
>
> I don't believe that...
>
> The only reason why the #0 chars are there is because it copies more than
> necessary ;)
>
> "Rob Kennedy" <me3@privacy.net> wrote in message
> news:32p0peF3irf2nU1@individual.net...
> > Skybuck Flying wrote:
> > > "Rob Kennedy" <me3@privacy.net> wrote in message
> > > news:32efhpF3js32sU1@individual.net...
> > >> That array actually gets assigned in three steps. First, it stores
> > >> 'Hell', then it stores 'o'#0, and then it fills the remaining byte
with
> > >> #0, too. In other words, the string literal is #0-extended to fit the
> > >> size of the buffer. The whole #0-padded string is stored in the EXE
> file
> > >> and gets copied into the array at run time.
> > >
> > > I don't think that's true Rob ;) ( I tested it once ;) )
> >
> > Do you think I just make this stuff up, pulling out of thin air?
> >
> > Whatever you tested, it wasn't this, or you didn't really understand
> > what you thought you saw. You have a history of misinterpretting what
> > you see.
> >
> > When I talk about what the compiler does and does not do, it's because
> > I've seen the generated code.
> >
> > > Try setting a[5] := char(66);
> > > Try setting a[6] := char(67);
> >
> > Don't tell me what to try. Try it yourself. Jeez.
> >
> > --
> > Rob
>
>



Relevant Pages

  • Re: ruby programming best practice
    ... is there a way to find out these spots in my program, like a compiler do in Delphi/C. ... I will naturally assume arr is an array. ... In delphi, for example, such error is detected while compile, e.g.. ... I know Ruby works differently, but is there a way exists, like a normal compiler, or something like FxCop for the C# language? ...
    (comp.lang.ruby)
  • Re: working with byte arrays
    ... > pure Delphi - and Delphi is often virtually unbeatable, ... > it uses an optimizing compiler. ... And in addition to what J French said, if you go to Advanced Compile options ... and check "Remove Array Bounds check", then array access will be even faster ...
    (microsoft.public.vb.general.discussion)
  • Dynamic Out of Bounds checking for array operator.
    ... Delphi has no way to access this via a dynamic array. ... the only problem is the compiler does not yet know the ... At compile time because the SetArrayBounds was not found for the array. ...
    (alt.comp.lang.borland-delphi)
  • Re: Problem closing app with big UDT
    ... Are you trying to pass the UDT between VB and Delphi, or do you just mean that the Delphi equivalent works fine? ... All the array sizes are multiples of 4, so the 4-byte alignment should be maintained throughout unless we screwed up somewhere. ... In any one app, maybe, but this dll is in production use in several different apps, in 3 different languages. ... So coming at it from a different direction is there any way I can, just in my VB app, send and receive the structure I need without actually passing it as a structure? ...
    (microsoft.public.vb.general.discussion)
  • Re: Problem closing app with big UDT
    ... Are you trying to pass the UDT between VB and Delphi, ... Passing it back and forth between a Delphi .dll to a VB application. ... ALL the data is of one of 3 types: Long, Double, or Byte array. ... In any one app, maybe, but this dll is in production use in several ...
    (microsoft.public.vb.general.discussion)