Re: [fpc-pascal] Executable with invisible window and IO enabled

2013-07-16 Thread Michael Van Canneyt



On Mon, 15 Jul 2013, luciano de souza wrote:


hello all,
I want to compile a program with no visible screen, but at the same
time, with input and output enabled.
If I use $apptype gui, the screen is invisible, but there are not
input and output.


Correction: there is input and output, just not standard input and output.
(the console, if you want)


If I use the standard $apptype console, the input and output is
enabled, but the screen is visible.
In Windows, how to obtain the both effects simultaneously?
Brook has an embeded web server. With one click on the executable, the
web server is opened. However, it's not my intention to keep the
window visible. Otherwise, the browser will read data from the input
and write data to the output.


It should not. A webserver reads/writes to port 80.

If it reads/writes to standard input/output, it only diagnostic information.

You should compile this app with $apptype GUI, and disable all diagnostic 
information
(i.e. comment out all writeln statements)

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Strings

2013-07-16 Thread Carsten Bager
Hi
I have a question about dynamic strings and memory allocation.
If you look at my example underneath, I depend on that a dynamic string always 
is assigned
memory space in one connected block. But will that always be the case in 
various operating
systems.

Carsten





Function Sum(p:pointer; len:LongInt):LongInt;
Type
  a_typ=array[0..pred(maxLongInt)] of byte;
  a=^a_typ;
var
  i:LongInt;
Begin
  result:=0;
  for i:=0 to len do
result:=result+a(p)^[i];
End;


Procedure test;
Var
  s:ansistring;
  i:integer;
Begin
  s:='Something';
  for i:=0 to 10 do
s:=s+'Test';
  if Sum(@s[1],length(s)) = 0 then
halt(0);
End;

Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Strings

2013-07-16 Thread Michael Schnell

On 07/16/2013 12:17 PM, Carsten Bager wrote:

If you look at my example underneath, I depend on that a dynamic string always 
is assigned
memory space in one connected block.
As the compiler allows for assigning a string to a pchar, the strings 
need to be compatible to C strings. Thus:
 - The content starts at the location the pchar points to and fills 
consecutive addresses

 - a $0 character is appended after the last relevant character.

Of course the OS is free to use the mapped hardware RAM address in a way 
that for DMA the string content might come in separate chunks.


Is this what you mean ?

- Michael
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Strings

2013-07-16 Thread Michael Van Canneyt



On Tue, 16 Jul 2013, Carsten Bager wrote:


Hi
I have a question about dynamic strings and memory allocation.
If you look at my example underneath, I depend on that a dynamic string always 
is assigned
memory space in one connected block. But will that always be the case in 
various operating
systems.


Yes, the data of a dynamic string is contained in one connected block.

The data of 2 dynamic strings may of course reside in 2 different blocks, i.e.,
it it not correct to say that all string data of the program is in the same 
connected block.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Strings

2013-07-16 Thread Jeppe Græsdal Johansen
Why not just skip all the encoding uncertainity of strings and use an 
array of byte/char?


It'll probably be a lot faster too

Den 16-07-2013 12:17, Carsten Bager skrev:

Hi
I have a question about dynamic strings and memory allocation.
If you look at my example underneath, I depend on that a dynamic string always 
is assigned
memory space in one connected block. But will that always be the case in 
various operating
systems.

Carsten





Function Sum(p:pointer; len:LongInt):LongInt;
Type
   a_typ=array[0..pred(maxLongInt)] of byte;
   a=^a_typ;
var
   i:LongInt;
Begin
   result:=0;
   for i:=0 to len do
 result:=result+a(p)^[i];
End;


Procedure test;
Var
   s:ansistring;
   i:integer;
Begin
   s:='Something';
   for i:=0 to 10 do
 s:=s+'Test';
   if Sum(@s[1],length(s)) = 0 then
 halt(0);
End;

Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Strings

2013-07-16 Thread Marco van de Voort
In our previous episode, Carsten Bager said:
> Function Sum(p:pointer; len:LongInt):LongInt;
> Type
>   a_typ=array[0..pred(maxLongInt)] of byte;
>   a=^a_typ;
> var
>   i:LongInt;
> Begin
>   result:=0;
>   for i:=0 to len do
> result:=result+a(p)^[i];
> End;

0..len is len+1 items.
 
> 
> Procedure test;
> Var
>   s:ansistring;
>   i:integer;
> Begin
>   s:='Something';
>   for i:=0 to 10 do
> s:=s+'Test';
>   if Sum(@s[1],length(s)) = 0 then

s[1] length(s) implies "lenght(s)" items. IOW the sum routine also
adds/accesses the final zero.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Strings

2013-07-16 Thread Carsten Bager
> Of course the OS is free to use the mapped hardware RAM address in a way 
> that for DMA the string content might come in separate chunks.
> 
> Is this what you mean ?
> 
> - Michael

Yes

Thanks

Carsten
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Strings

2013-07-16 Thread Carsten Bager
My code was just an example, to illustrate what I was aiming at. It is not 
actually used.
But I think you have a point

Carsten

> Why not just skip all the encoding uncertainity of strings and use an 
> array of byte/char?
> 
> It'll probably be a lot faster too

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: [Lazarus] Should TObject or TComponent have a Comment property?

2013-07-16 Thread vfclists .
On 15 July 2013 22:58, Kenneth Cochran  wrote:

>
>
>
> I completely disagree. It is the code that is the primary expression of
> intent not the comments. This is mainly accomplished through sensible
> identifier naming. Comments exist to compensate for a developer's inability
> to express intent through the code and IMHO should be reserved for this
> sole purpose. In most cases you should be able to look at a function
> signature and know exactly what that function's intent is. Likewise you
> should be able to tell the intent of a class by its name and the names of
> its public/published members. This is, at least, what I strive for in my
> own code. Bob Martin's "Clean Code" dedicates the entire 4th chapter to the
> discussion of comments and make some very compelling arguments for limiting
> their use.
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>

I have 2 main concerns here, a comment for the component itself which is
not particularly important and a comment for the component when I add it to
a form or data module. When I create a method I can add a comment to the
method. If I create a component in code, I can label that section of code,
but if I drag and drop a component from the palette onto the form what
option do I have?  Descriptive variable and component names have a habit of
getting too long. It is hardly for the end users sake unless the enduser is
a programmer. I just need something to help when working in the IDE, eg
hovering over a component and seeing the comment in addition to what is
current displayed.

-- 
Frank Church

===
http://devblog.brahmancreations.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: [Lazarus] Should TObject or TComponent have a Comment property?

2013-07-16 Thread waldo kitty

On 7/16/2013 17:56, vfclists . wrote:

I have 2 main concerns here, a comment for the component itself which is not
particularly important and a comment for the component when I add it to a form
or data module. When I create a method I can add a comment to the method. If I
create a component in code, I can label that section of code, but if I drag and
drop a component from the palette onto the form what option do I have?


if one doesn't know what a component does when they drag it from the pallet, 
shouldn't they have the docs open which explain that component?



Descriptive variable and component names have a habit of getting too long.


agreed... i hate typing in 10+ character var or routine names... especially 
since i'm still working on trying to move from the old DOS TP6 environment ;)



It is hardly for the end users sake unless the enduser is a programmer. I just
need something to help when working in the IDE, eg hovering over a component and
seeing the comment in addition to what is current displayed.


i feel ya, man... i feel ya O:)

--
NOTE: No off-list assistance is given without prior approval.
  Please keep mailing list traffic on the list unless
  private contact is specifically requested and granted.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Executable with invisible window and IO enabled

2013-07-16 Thread Graeme Geldenhuys
On 2013-07-16 09:10, Michael Van Canneyt wrote:
> 
> You should compile this app with $apptype GUI, and disable all diagnostic 
> information
> (i.e. comment out all writeln statements)


Exactly what Michael said. You can also enable you app to start-up in
the system tray. Not showing the main form by default.


Regards,
  - Graeme -


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal