Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-09

Q about FP additional questions

6 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

mike

Hello there.
(questions at the end of this message)

I spent an hour getting all the files I could need form your site a while back.

Note that I knew absolutely nothing about Pascal before last night, and only been involved minutely in Visual Basic development and web site design since April of this year.

Now I had a wonderful quality-time by my self with your FAQ and DOC files this early morning form app. 3.30 till app. 7.30.

After about 4 hours I wrote my first little exe, and not the regular boring

    writeln('hello world');

but rather, this to test some file writing abilities.

A file to generate somewhere around 1 Mb of data strings, marking start time and end time so I can see how quick this really is for my future needs.

It writes in average, on my puter, 8,22 Mb per seconds, so needless to say I am very pleased in comparance to VB which would take a few minutes just to run the generation loop.

Now I must also give you guys a serious patt on the back for really knowing what you are doing as far as building an excellent installer for the Windows environment.

I have not had to tweak or alter a single thing before I could compile my program.
(as opposed of DJGPP whihc didnt want to work after 6 hours of install attempts,
or even so, Visual Cpp that still tosses all sorts of weird outcommented code into
the generated applications.)

So finaly to my questions.

1) Is there a simple way to do
Char 2 Ascii Code ('A' => #65)
Char 2 Hex Code (#255 => $FF)
Char 2 Binary Code (#255 => %11111111)
in this kind of reversed conversion, already included or is that only possible the opposit way.

2) Is there an upper limit for how large a file the compiler can process?
I mean I could virtually write all my source code into one single text file,
and run it as is through the compiler.

and perhaps most importantly,

3) Is there a way to write DLL files with FreePascal, or can I call the executables in some way to perform the same operations?

Keep up the good work all of you, and I really hope you decide to make all your libraries ported to suit all operating systems.

I find it amazing, how quickly I picke dup on your excellent writing and the wonderful samples you include in the node files in your documentation.

Sincerely,

Mike J.

Reply by email

Barry Kelly
to mike
mike wrote
1) Is there a simple way to do Char 2 Ascii Code ('A' => #65)

Ord('A')

Char 2 Hex Code (#255 => $FF)

IntToHex(Ord('A'), 2)

(assuming 'uses SysUtils;' at the top).

Char 2 Binary Code (#255 => %11111111)

This isn't particularly useful (I've certainly never had a use for it) - it isn't in the RTL. You can get the desired effect with a loop of checking for Odd, then 'div 2'.

  x := Ord('A');
  s := '';
  while x > 0 do
  begin
    if Odd(x) then
      s := '1' + s
    else
      s := '0' + s;
    x := x div 2;
  end;
Show quoted text 5 lines
2) Is there an upper limit for how large a file the compiler can process? I mean I could virtually write all my source code into one single text file, and run it as is through the compiler.

That wouldn't be a good idea from a maintenance perspective. You should break it up into units, and include these units on the search path. You only have to include the main program filename on the compiler's command line - the compiler should find all the units by their names, as long as the appropriate files are on the search path.

For example, you might have the unit Stuff.pas (should be called Stuff.pas for auto-finding):

---8<---
unit Stuff;
interface
function Twice(x: Integer): Integer;
implementation
function Twice(x: Integer): Integer;
begin
  Result := x * 2;
end;
end.
--->8---

And have the program:

---8<---
{$apptype console}
uses Stuff;
var
  num: Integer;
begin
  Write('Enter number: ');
  Readln(num);
  Writeln('Double = ', Twice(num));
end.
--->8---
Show quoted text 5 lines
and perhaps most importantly, 3) Is there a way to write DLL files with FreePascal, or can I call the executables in some way to perform the same operations?

You use 'library' instead of 'program'. The above program could be written as a DLL that exported the Twice function:

---8<--- // SomeStuff.pas
library SomeStuff;
uses Stuff;
exports Twice;
begin
  // initialization code
end.
--->8---

Keep in mind that this will be using FreePascal's calling convention, which is most likely 'register' for Delphi compatibility (I didn't check recently). If you want to call the function from another language, you should use stdcall; change the 'Twice' declaration in the Stuff unit to this:

function Twice(x: Integer): Integer; stdcall;

-- Barry

If you're not part of the solution, you're part of the precipitate. Team JEDI: http://www.delphi-jedi.org NNQ - Quoting Style in Newsgroup Postings http://web.infoave.net/~dcalhoun/nnq/nquote.html

Reply by email

Marco van de Voort
to mike: Hello there. (questions at the end of this message) I spent an hour getting all the files…
Show quoted text 6 lines
I spent an hour getting all the files I could need form your site a while back. Note that I knew absolutely nothing about Pascal before last night, and only been involved minutely in Visual Basic development and web site design since April of this year.

Then I suggest some tutorials. E.g. searching on "Glenn Grotzinger" will certainly find one.

It writes in average, on my puter, 8,22 Mb per seconds, so needless to say I am very pleased in comparance to VB which would take a few minutes just to run the generation loop.

Welcome to compiled langauges :- )

Show quoted text 11 lines
Now I must also give you guys a serious patt on the back for really knowing what you are doing as far as building an excellent installer for the Windows environment. I have not had to tweak or alter a single thing before I could compile my program. (as opposed of DJGPP whihc didnt want to work after 6 hours of install attempts, or even so, Visual Cpp that still tosses all sorts of weird outcommented code into the generated applications.)

Pretty close to the reason why I ended up with FPC. Couldn't get GPC compiled, and the binaries were so _very_ outdated. But that is all ancient history now :-)

So finaly to my questions. 1) Is there a simple way to do Char 2 Ascii Code ('A' => #65)

writeln(ord('A'))

Char 2 Hex Code (#255 => $FF)
begin
 writeln(hexstr(longint('A'),2));
end.
Char 2 Binary Code (#255 => %11111111) in this kind of reversed conversion, already included or is that only possible the opposit way.
begin
 writeln(binstr(ord('A'),8));
end.
2) Is there an upper limit for how large a file the compiler can process?

That is hard to say. There is no exact limit probably, but the compiler needs more memory to store the already compiled parts, then with seperate (or divided in units) parts.
However I don't think there is a limit below several megabytes.

I mean I could virtually write all my source code into one single text file, and run it as is through the compiler.

You could yes, but you would loose overview probably.

Several MBs must be possible I think, with an average amount of memory by todays standards.

Show quoted text 5 lines
and perhaps most importantly, 3) Is there a way to write DLL files with FreePascal, or can I call the executables in some way to perform the same operations?

It's possible with the Win32 version, and IIRC there are examples in the examples/demo section.

Show quoted text 6 lines
Keep up the good work all of you, and I really hope you decide to make all your libraries ported to suit all operating systems. I find it amazing, how quickly I picke dup on your excellent writing and the wonderful samples you include in the node files in your documentation.

The documentation is really good. We have to thank Michael for that.

Reply by email

Michail A.Baikov
to Pavel V. Ozerski

Is good news! :)

Hello, Today I found that Watcom C/C++ and Fortran are available for free

downloads from http://www.openwatcom.org/download.html.

They can contain good replacements for currently used in FPC binutils

(That could be important first for OS/2 port: now it has

Show quoted text 10 lines
a chance to became free from EMX!). Sincerely, Pavel _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Unknown author
to Pavel V. Ozerski: Today I found that Watcom C/C++ and Fortran are available for free downloads from…

To:
Organization: Sechenov Institute of Evolutionary Physiology and Biochemistry, Russian Academy of Science
From: (Pavel V. Ozerski)
Date sent: Fri, 28 Sep 2001 12:42:52 +0400 (MSD) Subject: [fpc-devel]Watcom is available
Send reply to:

Hello,

Show quoted text 5 lines
Today I found that Watcom C/C++ and Fortran are available for free downloads from http://www.openwatcom.org/download.html. They can contain good replacements for currently used in FPC binutils (That could be important first for OS/2 port: now it has a chance to became free from EMX!).

yes, I got the news from OpenWatcom announcement list as well. It's definitely interesting, but the way might not be as straightforward as it could seem. First, I don't know the exact license conditions yet (for this binary patch, that's it - this might be different from the final open-source release). Second, we still have to modify the compiler first to make Watcom assembler/linker useable. Anyway - yes, it's a good news, thanks for it.

Tomas

Reply by email