[fpc-pascal] Convert to int64 note

2017-07-13 Thread james
I've been trying to get my programs to compile without any warnings or notes, 
but I keep getting this one:

promill.pas(2137,42) Hint: Converting the operands to "Int64" before doing the 
subtract could prevent overflow errors.

I get it a lot, but this is the line the above example is from:

Last_GS:=G_End-(Max_Program_To_Display-1);

Can someone please explain that this hint means and how I would convert the 
operands to "Int64" as recommended?

James

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

Re: [fpc-pascal] Convert to int64 note

2017-07-14 Thread james
>What's the type of each variable?

Last_GS,G_End : longint;
Max_Program_to_Display : Word;

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Santiago A.
Sent: Friday, July 14, 2017 7:00 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Convert to int64 note

El 14/07/2017 a las 1:13, ja...@productionautomation.net escribió:
> I've been trying to get my programs to compile without any warnings or notes, 
> but I keep getting this one:
>
> promill.pas(2137,42) Hint: Converting the operands to "Int64" before doing 
> the subtract could prevent overflow errors.
>
> I get it a lot, but this is the line the above example is from:
>
> Last_GS:=G_End-(Max_Program_To_Display-1);
>
> Can someone please explain that this hint means and how I would convert the 
> operands to "Int64" as recommended?
>
> James
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

What's the type of each variable?

--
Saludos

Santiago A.

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

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

Re: [fpc-pascal] Convert to int64 note

2017-07-14 Thread james
>If you declare Last_GS as int64, you should not get the warning.

I declared both Last_GS and G_End as int64, leaving Max_Program_to_Display as a 
word and still get the warning.  If I also make Max_Program_to_Display int64, 
then I do not get the warning.   I believe it's due to the -1. If 
Max_Program_To_Display was a 0 then subtracting 1 from it would be out of range 
from a word for that portion of the formula, even though the end result would 
fit in Last_GS

>Last_GS:=G_End-(longint(Max_Program_To_Display)-1);
This aso fixes the warning if I leave all my variables alone.  If I understand 
this correctly in this case longint() is a function that returns a longint 
variable to be used in the calculation, so when it does the -1 it's ok it that 
part of the formula ends up being negative.

So now my question is, which is the best method to use?  My thinking with 
declaring Max_Program_To_Display as a word was that this value has no meaning 
if it is negative, and actually a word is way too generous for this value, a 
byte would be overkill.  Last_GS and G_End could be very large, so that's the 
reason for the longint.  So I can either declare Max_Program_to_Dispalay as a 
longint and use more memory for that variable, or use a longint() function in 
my formula and that calculation would have one more function to process, or 
turn off the warnings but then there could be a condition where I could get an 
out of range result during the computation even though the final result would 
have been in range.. but this happens sometimes so I would rather fix it to 
never happen.

I'm from the old school way of thinking that programs should use as little 
memory and be as efficient as possible, after all some of my computers only had 
4K of RAM,  but I'm wondering if that has become irrelevant with modern 
computers.
Does it really matter anymore how much memory I use up with variables?   Maybe 
I should just declare all whole number variables as int64 and all decimal 
numbers as Double and not worry about how much memory I use, after all I have 
gigabytes of ram to use now, not 64K blocks of ram that each turbo pascal unit 
had to fit into.  Even if I had 1 million int64 variables and 1 million double 
variables, that would only end up being 18MB of memory, not much of dent in 
1GB... and most pcs have more than 1GB of RAM.  

I suppose it would take longer to process all formulas with int64 and double 
variables compared to using smaller variables, but then again processor speed 
is also very fast now, so should I even be bothered with it?

I'm curious what the general method is now?   

James


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

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-07-20 Thread james
I've been having very good results with the accelerated putimage() in ptcgraph. 
   I am wondering if this modification could be added to 3.04, or some future 
release,  as I think everyone would want putimage() to happen as fast as 
possible.I can't figure out how or where to submit this though.   I got the 
original code from here: https://sourceforge.net/p/ptcpas/code/785/tree/trunk/  
and  the code modified code I have is here: 
https://github.com/Zaaphod/ptcpas/tree/Avoid_ReChecking_Bitblt.   I don't see 
any method to submit something similar to a pull request though.   Is there 
some method to contribute code to the PTCPAS project?  

I am also wondering if it would be beneficial to accelerate other procedures in 
the same way especially getimage()   I'm wanting to make it appear as it an 
object moves across the screen so I want to getimage() a small portion of the 
screen, copy the image variable, draw the object in the copy, putimage() the 
copy to show the object, then when it's time to move it, putimage() the 
original back, then start the process over again in the next location.

James

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

[fpc-pascal] Very slow startup of Frepascal programs on just one system

2018-08-22 Thread James
I am experiencing very slow startup of all of my freepascal programs for
windows on just one computer.  Normally they all start pretty much
instantly, but I just got a brand new Dell XPS desktop computer and they are
all starting up VERY slowly,  even simple console programs.. Even 'Hello
World'  take over 50 full seconds to start, even when running from a RAM
Drive.   Does anyone have any idea what could be going on to cause such a
slowdown?They all run faster than this on an ancient XP computer, I
don't understand what's taking so long on this new PC. All my programs
are compiled with FPC 3.0.4rc1 and normally start instantly even on my
slowest windows tablet pc. except for this new computer, and everything else
on this computer starts very fast,  it's only all of my freepascal programs
that start very very slow.  Once my programs finally.. eventually.. Get
around to starting, they execute just fine,  no further delay in processing,
disk access, or graphics.   I thought it might be smart screen or a virus
scanner causing the delay, so I turned those off,  still have a huge delay.
No matter what I do, every freepascal program I have ALWAYS takes at least
50 seconds to start on this system.

 

The system is this one:
https://www.dell.com/en-us/work/shop/desktop-and-all-in-one-pcs/xps-tower-sp
ecial-edition/spd/xps-8930-se-desktop/cto8930w10pcfl4h?ref=569_prodTitle
but it has been upgraded to 64GB of RAM, and a solid state hard drive.   The
processor is Intel Core i7-8700K @3.7GHz and is running windows 10 Pro
64bit.  This should be the fastest computer I have, yet it's the only one
with this issue.

 

Hello world program is this:

Begin

Writeln('Hello World');

Readln;

End.

 

Any ideas on what may be going on?   This is pretty much un-usable with
these huge delays every time I need to start one of my freepascal programs.


 

 

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

Re: [fpc-pascal] Very slow startup of Frepascal programs on just one system

2018-08-22 Thread James
>Does the same happen for GUI programs compiled with FPC on that machine?
I don't have any FPC GUI programs, they are all console programs, some console 
with ptcgraph 

>As a test try to disable your anti virus and/or Windows Defender.

>Pretty much only security software/anti virus.

Yes that is what it was... there was some free trial of Mcafee antivirus 
preinstalled on this system, and it had a feature that scanned every single 
file every time it was opened... I have NO idea how they can possibly take over 
50 seconds to scan a 70KB hello world program, they have an severe bug in their 
scanner, it's a silly feature anyway, because if you scan every file as it's 
put on the system, they why do you need to scan it again every time you use the 
file.   Anyway the free trial was going to expire in 2 days anyway, and the 
delay was completely unacceptable, so I just removed the entire thing and 
activated windows defender and now everything is running normally.

Thanks everyone for the help getting to the problem!

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

[fpc-pascal] Windows programming tutorials for FPC

2018-11-02 Thread James
I've been programming for decades with Pascal, starting with Turbo Pascal, and 
for a few years now with Freepascal, and even wrote really complicated console 
windows programs with Freepascal that do windows function calls... But now I 
find that I would like to write a few windows GUI programs,  and well... I'm 
clueless... I never learned windows GUI programming and don't have a clue about 
how it's done, it's always been faster and easier to just keep doing what I 
already understand, but now I have a few applications to write what would be 
much better suited to a native windows application, so,   I am wondering if 
there are any tutorials out there, hopefully specific to Freepascal and/or 
Lazarus.  I need really basic stuff like how to open a message box, or how to 
use windows file open, or save-as dialog boxes.. etc.. even a hello world 
tutorial would be helpful... ok, so ZERO windows programming experience here... 
  Any advice on where to start?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
That is correct, I have only ever done console programming, but now I find I'm 
lost trying to do any kind of GUI programming.I have a very simple program 
that works as a console application, but what I would like to do is have it use 
the Windows "Save AS' Dialog to allow the user to save the file using the 
windows GUI interface, so the user can navigate through directory structures 
and save the file.

 

I looked at a few tutorials and see how to make a form and put some buttons on 
it, but I'm still trying to figure out how to get the save-as box to come up 
and how to then use the given file name and path in the program for the actual 
write operation..  Here’s my console program.. it’s pretty simple, but I really 
don’t know where to even start to convert it into a GUI program.  On line 51, 
if the output file has not been defined yet, I want to launch the save-as 
dialog, then on line 54, assign whatever save-as returns to my OutputFileName 
Variable.  

 

 

Program JobsList;

Uses CRT,Classes,Sysutils;

Var

   TapFileRemainder,TapFileHeader,TapFileJobsList : tstrings;

   TapFileName,TapFileData,OutputTapFileName  : String;

   TapFile: Text;

   TapFileHeaderActive: Boolean;

   StringCount: LongInt;

Begin

   If ParamStr(1)<>'' Then

  Begin

 TapFileName:=ParamStr(1);

 If FileExists(TapFileName) Then

Begin

   TapFileHeaderActive:=True;

   Assign(TapFile,TapFileName);

   Reset(TapFile);

   TapfileHeader:=TStringlist.Create;

   TapfileJobsList:=TStringlist.Create;

   TapfileRemainder:=TStringlist.Create;

   While not(EOF(TapFile)) do

  Begin

 Readln(Tapfile,TapFileData);

 If TapfileHeaderActive then

Begin

   If TapFileData='Call [Subroutines]' Then

  Begin

 Writeln('Subroutine Section Found');

 TapFileHeaderActive:=False

  End

   Else

  If Copy(TapFileData,1,15)='Tap File Name =' Then

  Begin

 
OutputTapFileName:=Copy(TapFileData,16,Length(TapFileData)-15);

 Writeln('Saving to: '+OutputTapFileName);

  End

   Else

  TapfileHeader.Add(TapFileData)

End

 Else

Begin

   If Copy(TapFileData,1,6)='[Job #' Then

  Begin

 Writeln(TapFileData);

 TapFileJobsList.Add('Call '+TapFileData);

  End;

   TapfileRemainder.Add(TapFileData)

End;

  End;

   Close(TapFile);

   If OutputTapFileName='' Then

  Begin

 {Do something to get filename from windows Save-As dialog}

 OutputTapFileName:= 
Whatever-was-received-by-Windows-Save-As-dialog;

  End;

   If OutputTapFileName<>'' Then

  Begin

 Writeln('Writing 
',TapFileHeader.count+TapFileJobsList.count+TapFileRemainder.count,' Lines to: 
'+OutputTapFileName);

 Assign(TapFile,OutputTapFileName);

 ReWrite(TapFile);

 If TapFileHeader.count > 1 then

 For StringCount:=0 to TapFileHeader.count-1 do

Writeln(TapFile,TapFileHeader[StringCount]);

 If TapFileJobsList.count > 1 then

 For StringCount:=0 to TapFileJobsList.count-1 do

Writeln(TapFile,TapFileJobsList[StringCount]);

 If TapFileRemainder.count > 1 then

 For StringCount:=0 to TapFileRemainder.count-1 do

Writeln(TapFile,TapFileRemainder[StringCount]);

 Close(TapFile);

  End

   Else

  Begin

 Writeln ('No Output Tap File Specified in Program');

 Readln;

  End;

   TapFileHeader.Free;

   TapFileJobsList.Free;

   TapFileRemainder.Free;

End

 Else

Begin

   Writeln (TapFileName,' Not Found

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
Thanks for the gersavefilenamea idea, I have used windows API function calls 
before in my Windows Console programs, so I thought I would try to get 
getsavefilenamea or ifilesavedialog to work in my console program.  So I 
thought I would start small and get message boxes to work on my console 
program, this was actually pretty easy, I just added the windows unit to my 
program and then changed my writeln's to 
windows.messagebox(0,pchar(TapFileName+' Not Found'),pchar('Error'),MB_OK);

And poof I get a message box when I encounter the error, and the program waits 
until I hit OK to continue.  Neat!  

 

So it's looking promising, that perhaps I can just keep it a console program 
that launches the save-as dialog somehow when needed.This idea appeals to 
me for several reasons, first, I need to write the status of things somewhere,  
it's easy to just have a writeln in a console application, but in a windows 
application, I have no idea how I would make some kind of text box to display 
this information.   Also, I want this program to start executing immediately, 
and if no user intervention is needed, I want it to launch, perform all tasks, 
and exit.  I just don't have anything to put on a form because the intent is 
that the user would only interact with this program if it encountered an error, 
or if the user needed to specify the output file name.

 

So my question is, how can I use Ifilesavedialog with just FreePascal in a 
console application?  I tried just accessing it the same as I did messagebox, 
but I just get an error stating the function is not found.   It seems like I 
ran across this before, I wanted to use a Windows API function that was not 
included in the windows unit and I was somehow able to add access to it on my 
own,  but I just can't recall now what function that was, or what program I was 
working on that needed it, or how it was accomplished.   Perhaps it is in the 
windows unit, or another unit, but I'm just not calling it correctly.   Current 
version of my program that uses message boxes for errors is below.

 

James

 

Program JobsList;

Uses CRT,Classes,Sysutils,windows;

Var

   TapFileRemainder,TapFileHeader,TapFileJobsList : tstrings;

   TapFileName,TapFileData,OutputTapFileName  : AnsiString;

   TapFile: Text;

   TapFileHeaderActive: Boolean;

   StringCount: LongInt;

Begin

   If ParamStr(1)<>'' Then

  Begin

 TapFileName:=ParamStr(1);

 If FileExists(TapFileName) Then

Begin

   TapFileHeaderActive:=True;

   Assign(TapFile,TapFileName);

   Reset(TapFile);

   TapfileHeader:=TStringlist.Create;

   TapfileJobsList:=TStringlist.Create;

   TapfileRemainder:=TStringlist.Create;

   While not(EOF(TapFile)) do

  Begin

 Readln(Tapfile,TapFileData);

 If TapfileHeaderActive then

Begin

   If TapFileData='Call [Subroutines]' Then

  Begin

 Writeln('Subroutine Section Found');

 TapFileHeaderActive:=False

  End

   Else

   If Copy(TapFileData,1,15)='Tap File Name =' Then

  Begin

 
OutputTapFileName:=Copy(TapFileData,16,Length(TapFileData)-15);

 Writeln('Saving to: '+OutputTapFileName);

  End

   Else

  TapfileHeader.Add(TapFileData)

End

 Else

Begin

   If Copy(TapFileData,1,6)='[Job #' Then

  Begin

 Writeln(TapFileData);

 TapFileJobsList.Add('Call '+TapFileData);

  End;

   TapfileRemainder.Add(TapFileData)

End;

  End;

   Close(TapFile);

   If OutputTapFileName='' Then

  Begin

 {Do something to get filename from windows Save-As dialog}

 {OutputTapFileName:= 
Whatever-was-received-by-Windows-Save-As-dialog;}

  End;

   If OutputTapFileName<>'' Then

  Begin

 Writeln('Writing 
',TapFileHeader.count+TapFileJobsList.count+TapFileRemainder.count,' Lines to: 
'+OutputTapFileName);

 

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
>And you can't just pop up a dialog window without having a window/form in the 
>first place.  

That’s probably my problem…  My idea of just calling up the windows-API to get 
the save-as dialog probably won’t work without a form, even though I was able 
to get message boxes working


>In general, the logic of a GUI based program (regardless if Windows, macOS, 
>Linux, etc) simply is different from a console program. Your console program 
>main loop simply  pretty much just becomes a procedure within the GUI main 
>loop.



This logic difference is what is most confusing to me.   I just don’t know 
where to put my main program and I don’t know how to output things to some kind 
of text box.   I don’t want the user to do anything at all unless it’s 
necessary… so if everything is set up correctly, the program opens, does it’s 
thing, writes some status stuff to a text box and closes,  no buttons to push 
or anything…. If I get a GUI program to work, I guess I can put a percentage 
complete barograph somewhere.  If there’s an error, I need to stop and wait for 
acknowledgement of the error, or if the output file was not specified, I want 
the Save-As box to just open up on it’s own with out anyone pushing any 
buttons, and when the save-as box is closed the process completes on it’s own 
and the program exits without any further user intervention. 

I’ve been tinkering with Lazarus, and I managed to get a form with some buttons 
based on the examples, and I did make one button open the save-as box… but I’m 
clueless on how to make the save-as box only come up when needed and by a 
programming command, not because someone pushed a button.  I still can’t figure 
out how to write my writeln’s into a text box of some sort.I get the idea… 
instead of a sequential program the executes from beginning to end,  everything 
kind of all happens at the same time

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

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
Thanks for the suggestion... 

I put my code in the OnCreate event as you suggested, but when I try to compile 
it, I get wrong number of parameters specified for call to Assign... my code 
worked before, and I have no idea what other parameters it could want or why it 
would be any different than my console application.

I'm doing:
Var  
   TapFileName : AnsiString;
   TapFile  : Text;

Assign(TapFile,TapFileName);

Any ideas why this works in FPC but not in Lazarus?

James

-Original Message-
From: fpc-pascal  On Behalf Of Luca 
Olivetti
Sent: Saturday, November 3, 2018 4:47 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

El 3/11/18 a les 21:20, James ha escrit:

> 
> I’ve been tinkering with Lazarus, and I managed to get a form with 
> some buttons based on the examples, and I did make one button open the 
> save-as box… but I’m clueless on how to make the save-as box only come 
> up when needed and by a programming command, not because someone 
> pushed a button.  I still can’t figure out how to write my writeln’s 
> into a text box of some sort.I get the idea… instead of a 
> sequential program the executes from beginning to end,  everything 
> kind of all happens at the same time


Try this:

-put a memo on the form (say, memo1) and a save dialog.
-in the object inspector double click on the OnCreate event of the form.
-this will create a FormCreate method. Put your code there (including the 
opening of the save dialog if needed).
-in your code show diagnostics messages in the memo
(mem1.lines.add('whatever'))
-at the end of your code, if everything is OK, add

 Application.ShowMainForm:=false;
 Application.Terminate;


This way, if there are no errors the form won't show, otherwise it will show 
whatever you put in the memo.

Tip: if your code will take a significant amount of time put at the beginning

Screen.Cursor:=crHourGlass;

and at the end

Screen.Cursor:=crDefault;


Bye
--
Luca
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
It’s not a snippet, that’s the entire thing.   It’s pretty simple, just a 
sequential set of events to fix a file.  It would be a great help if you could 
get me an example of how to make this work.

 

James

 

From: fpc-pascal  On Behalf Of Ralf 
Quint
Sent: Saturday, November 3, 2018 5:57 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

 

On 11/3/2018 1:20 PM, James wrote:

>And you can't just pop up a dialog window without having a window/form in the 
>first place.  

That’s probably my problem…  My idea of just calling up the windows-API to get 
the save-as dialog probably won’t work without a form, even though I was able 
to get message boxes working


>In general, the logic of a GUI based program (regardless if Windows, macOS, 
>Linux, etc) simply is different from a console program. Your console program 
>main loop simply  pretty much just becomes a procedure within the GUI main 
>loop.




This logic difference is what is most confusing to me.   I just don’t know 
where to put my main program and I don’t know how to output things to some kind 
of text box.   I don’t want the user to do anything at all unless it’s 
necessary… so if everything is set up correctly, the program opens, does it’s 
thing, writes some status stuff to a text box and closes,  no buttons to push 
or anything…. If I get a GUI program to work, I guess I can put a percentage 
complete barograph somewhere.  If there’s an error, I need to stop and wait for 
acknowledgement of the error, or if the output file was not specified, I want 
the Save-As box to just open up on it’s own with out anyone pushing any 
buttons, and when the save-as box is closed the process completes on it’s own 
and the program exits without any further user intervention. 

I had that problem many years ago as well, having literally written hundreds of 
console of TUI based programs, mainly on DOS, myself. And then switching some 
of them to a GUI program in Delphi (there was no Lazarus at that time) took 
quite a bit of rethinking of  a couple of decades habits in console/command 
line ways or even self written TUI programs.



I’ve been tinkering with Lazarus, and I managed to get a form with some buttons 
based on the examples, and I did make one button open the save-as box… but I’m 
clueless on how to make the save-as box only come up when needed and by a 
programming command, not because someone pushed a button.  I still can’t figure 
out how to write my writeln’s into a text box of some sort.I get the idea… 
instead of a sequential program the executes from beginning to end,  everything 
kind of all happens at the same time

 

Yup, all the windows (as in GUI) stuff happens all the time, at the same time 
as your actual program. I have no had a program myself where I had a dialog 
"come up out of the blue" (as you kind of describe it), but I have written a 
lot of data conversion programs that at some point required to open up an 
additional open or save dialog. A lot though depends on what the actual logic 
behind the actual processing of your console program is. A lot of times, it 
might take a bit of re-organizing.
I am a bit short of time, as I am dealing on and off all day with some CERT 
stuff, but I will see that I take a closer look at that program (snippet?) that 
you posted later today or tomorrow morning  and return a rough sample of a GUI 
"solution" for it...

Ralf

 

 


 
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=icon>
 

Virus-free.  
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=link>
 www.avast.com 

 

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

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-04 Thread James
This is very interesting, thank you for the code on how to define the 
GetSaveFileNameA function.  I wrote a sample program to get it to work, but I 
think I have some syntax wrong, or maybe I'm not initializing something 
correctly.   It compiles ok, but it doesn't execute even my writeln's, I just 
get an exit code = 1

James 

Program TestGetSaveFileNameA;
Uses CRT,Classes,Sysutils,windows;
Type
TOpenFileNameAHookProc = function(Wnd: HWND; Msg: UINT; wParam: WPARAM;
lParam: LPARAM): UINT stdcall;

TOpenFileNameA = Packed Record
lStructSize: DWord;
hWndOwner: HWND;
hInstance: HINST;
lpstrFilter: PChar;
lpstrCustomFilter: PChar;
nMaxCustFilter: DWord;
nFilterIndex: DWord;
lpstrFile: PChar;
nMaxFile: DWord;
lpstrFileTitle: PChar;
nMaxFileTitle: DWord;
lpstrInitialDir: PChar;
lpstrTitle: PChar;
Flags: DWord;
nFileOffset: Word;
nFileExtension: Word;
lpstrDefExt: PChar;
lCustData: LPARAM;
lpfnHook: TOpenFileNameAHookProc;
lpTemplateName: PChar;
lpEditInfo: Pointer;// Undocumented?
lpstrPrompt: PChar;
_Reserved1: Pointer;
_Reserved2: DWord;
FlagsEx: DWord;
End;
POpenFileNameA = ^TOpenFileNameA;

Function GetSaveFileNameA(arg: POpenFileNameA): windows.bool; stdcall; external 
'comdlg32' name 'GetSaveFileNameA';

Var
   TFilename  : TOpenFileNameA;
   PFilename  : POpenFileNameA;

Begin
   Writeln('Start');
   TFilename.lpstrInitialDir:=Pchar('I:\');
   Pfilename:=@Tfilename;
   Writeln(GetSaveFileNameA(PFilename));
   Writeln('Finished');
   Readln;
End.





-Original Message-
From: fpc-pascal  On Behalf Of Ewald
Sent: Sunday, November 4, 2018 8:06 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

On 11/03/2018 09:04 PM, James wrote:
> So my question is, how can I use Ifilesavedialog with just FreePascal 
> in a console application?

First off, the IFileSaveDialog is an interface, not a simple function.
So, you'll need to:
- Include the right units from freepascal (ActiveX and comobj
   IIRC)
- Initialize and finalize the COM subsystem (see CoInitialize
   and CoUninitialize)
- Use the CoCreateInstance to instantiate an IFileSaveDialog,
   etc.. I've never used the IFileSaveDialog myself, so have a
   look at
https://msdn.microsoft.com/en-us/library/windows/desktop/bb776913%28v=vs.85%29.aspx#usage

That's the nice thing about the GetSaveFileNameA function: one call, and you're 
done :-)

Now, if this function is not defined in the windows unit (which could be the 
case), you can either look into some other units or simply define it
yourself:

=== code begin ===
Type
TOpenFileNameAHookProc = function(Wnd: HWND; Msg: UINT; wParam: WPARAM;
lParam: LPARAM): UINT stdcall;

TOpenFileNameA = Packed Record
lStructSize: DWord;
hWndOwner: HWND;
hInstance: HINST;
lpstrFilter: PChar;
lpstrCustomFilter: PChar;
nMaxCustFilter: DWord;
nFilterIndex: DWord;
lpstrFile: PChar;
nMaxFile: DWord;
lpstrFileTitle: PChar;
nMaxFileTitle: DWord;
lpstrInitialDir: PChar;
lpstrTitle: PChar;
Flags: DWord;
nFileOffset: Word;
nFileExtension: Word;
lpstrDefExt: PChar;
lCustData: LPARAM;
lpfnHook: TOpenFileNameAHookProc;
lpTemplateName: PChar;
lpEditInfo: Pointer;// Undocumented?
lpstrPrompt: PChar;
_Reserved1: Pointer;
_Reserved2: DWord;
FlagsEx: DWord;
End;
POpenFileNameA = ^TOpenFileNameA;

Function GetSaveFileNameA(arg: POpenFileNameA): windows.bool; stdcall; external 
'comdlg32' name 'GetSaveFileNameA'; === code end ===


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

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-04 Thread James
I used System.Assign and now I have my program working in Lazarus,  I am 
exploring both options of making it a real windows application with Lazarus and 
a console program that can launch save-as.

The Lazarus version is mostly working in Lazarus, but instead of everything 
happening before the form is loaded, is there a way I could make the form 
first, then just start processing everything, so that my messages I send to 
memo1 show up as it's processing?  I'm guessing I need to move my program from 
On-create to somewhere else so it runs after the memo box is showing... but I 
don't know where I would move it to.  Any suggestions?

James  Richters

-Original Message-
From: fpc-pascal  On Behalf Of Luca 
Olivetti
Sent: Saturday, November 3, 2018 6:15 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

El 3/11/18 a les 23:04, James ha escrit:
> Thanks for the suggestion...
> 
> I put my code in the OnCreate event as you suggested, but when I try to 
> compile it, I get wrong number of parameters specified for call to Assign... 
> my code worked before, and I have no idea what other parameters it could want 
> or why it would be any different than my console application.
> 
> I'm doing:
> Var
> TapFileName : AnsiString;
> TapFile  : Text;
> 
> Assign(TapFile,TapFileName);
> 
> Any ideas why this works in FPC but not in Lazarus?

Because Assign is a method of the form. Use AssignFile or System.Assign.
BTW: what I explained before is *not* how a gui application is usually written 
but it should work in your case.

Bye
--
Luca
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-04 Thread James
Thank you for this example!  It works perfectly and I now have my console 
program putting up message boxes and opening a Save-As box as needed.

James 

-Original Message-
From: fpc-pascal  On Behalf Of 
Alexander Grotewohl
Sent: Sunday, November 4, 2018 11:48 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

Program TestGetSaveFileNameA;
Uses windows, commdlg;

Var
TFilename  : TOpenFileNameA;

ret: array[0..100] of char;

Begin
Writeln('Start');

fillchar(TFileName, sizeof(TFileName), 0);
TFileName.lStructSize:=sizeof(TFileName);

TFileName.hwndOwner:=0;
TFileName.lpstrFile:=ret;
TFileName.lpstrFile[0]:=#0;
TFileName.lpstrFilter:='Text Files (*.txt)'+#0+'*.txt'+#0;
TFileName.nMaxFile:=100;
TFileName.Flags := OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_HIDEREADONLY;
TFileName.lpstrDefExt:='txt';

Writeln(GetSaveFileNameA(@TFilename));
Writeln('Finished with '+strpas(TFileName.lpstrFile));
Readln;
End.


On 11/4/2018 11:21 AM, James wrote:
> This is very interesting, thank you for the code on how to define the 
> GetSaveFileNameA function.  I wrote a sample program to get it to work, but I 
> think I have some syntax wrong, or maybe I'm not initializing something 
> correctly.   It compiles ok, but it doesn't execute even my writeln's, I just 
> get an exit code = 1
>
> James
>
> Program TestGetSaveFileNameA;
> Uses CRT,Classes,Sysutils,windows;
> Type
>   TOpenFileNameAHookProc = function(Wnd: HWND; Msg: UINT; wParam: 
> WPARAM;
> lParam: LPARAM): UINT stdcall;
>
>   TOpenFileNameA = Packed Record
>   lStructSize: DWord;
>   hWndOwner: HWND;
>   hInstance: HINST;
>   lpstrFilter: PChar;
>   lpstrCustomFilter: PChar;
>   nMaxCustFilter: DWord;
>   nFilterIndex: DWord;
>   lpstrFile: PChar;
>   nMaxFile: DWord;
>   lpstrFileTitle: PChar;
>   nMaxFileTitle: DWord;
>   lpstrInitialDir: PChar;
>   lpstrTitle: PChar;
>   Flags: DWord;
>   nFileOffset: Word;
>   nFileExtension: Word;
>   lpstrDefExt: PChar;
>   lCustData: LPARAM;
>   lpfnHook: TOpenFileNameAHookProc;
>   lpTemplateName: PChar;
>   lpEditInfo: Pointer;// Undocumented?
>   lpstrPrompt: PChar;
>   _Reserved1: Pointer;
>   _Reserved2: DWord;
>   FlagsEx: DWord;
>   End;
>   POpenFileNameA = ^TOpenFileNameA;
>
> Function GetSaveFileNameA(arg: POpenFileNameA): windows.bool; stdcall; 
> external 'comdlg32' name 'GetSaveFileNameA';
>
> Var
> TFilename  : TOpenFileNameA;
> PFilename  : POpenFileNameA;
>
> Begin
> Writeln('Start');
> TFilename.lpstrInitialDir:=Pchar('I:\');
> Pfilename:=@Tfilename;
> Writeln(GetSaveFileNameA(PFilename));
> Writeln('Finished');
> Readln;
> End.
>
>
>
>
>
> -Original Message-
> From: fpc-pascal  On Behalf 
> Of Ewald
> Sent: Sunday, November 4, 2018 8:06 AM
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] Windows programming tutorials for FPC
>
> On 11/03/2018 09:04 PM, James wrote:
>> So my question is, how can I use Ifilesavedialog with just FreePascal 
>> in a console application?
> First off, the IFileSaveDialog is an interface, not a simple function.
> So, you'll need to:
>   - Include the right units from freepascal (ActiveX and comobj
> IIRC)
>   - Initialize and finalize the COM subsystem (see CoInitialize
> and CoUninitialize)
>   - Use the CoCreateInstance to instantiate an IFileSaveDialog,
> etc.. I've never used the IFileSaveDialog myself, so have a
> look at
> https://msdn.microsoft.com/en-us/library/windows/desktop/bb776913%28v=
> vs.85%29.aspx#usage
>
> That's the nice thing about the GetSaveFileNameA function: one call, 
> and you're done :-)
>
> Now, if this function is not defined in the windows unit (which could 
> be the case), you can either look into some other units or simply 
> define it
> yourself:
>
> === code begin ===
> Type
>   TOpenFileNameAHookProc = function(Wnd: HWND; Msg: UINT; wParam: 
> WPARAM;
> lParam: LPARAM): UINT stdcall;
>
>   TOpenFileNameA = Packed Re

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-04 Thread James
Thank you everyone who helped me with this.  I have both the Lazarus version 
and the FPC console version both working with a Save-As  dialog and message 
boxes for errors.  Basic functionality is working great with both methods.  
Since it's such a simple program, I'll tinker with it with both methods for a 
while and use it as a learning process.   I am encouraged by getting this to 
work in Lazarus, so it's probably time I took to time to learn more about it 
instead of always writing console applications, I can see where it would be 
great to have some buttons for options and things like that... and at the same 
time I am thrilled to have such capability in my console applications!  

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

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-12 Thread James
I've been using the example below to use the Save-as dialog in my console 
program, and it works great, but I would like to be able to detect if the user 
pushes either the red X or the cancel button in the dialog.   I am supplying a 
suggested default name, and what's happening is if the user cancels or hits the 
red X, it just saves the file using the suggested default name, but the correct 
behavior would be to not save anything.   I'm not sure how this is normally 
done with GetSaveFileNameA.


-Original Message-
From: fpc-pascal  On Behalf Of 
Alexander Grotewohl
Sent: Sunday, November 4, 2018 11:48 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

Program TestGetSaveFileNameA;
Uses windows, commdlg;

Var
TFilename  : TOpenFileNameA;

ret: array[0..100] of char;

Begin
Writeln('Start');

fillchar(TFileName, sizeof(TFileName), 0);
TFileName.lStructSize:=sizeof(TFileName);

TFileName.hwndOwner:=0;
TFileName.lpstrFile:=ret;
TFileName.lpstrFile[0]:=#0;
TFileName.lpstrFilter:='Text Files (*.txt)'+#0+'*.txt'+#0;
TFileName.nMaxFile:=100;
TFileName.Flags := OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_HIDEREADONLY;
TFileName.lpstrDefExt:='txt';

Writeln(GetSaveFileNameA(@TFilename));
Writeln('Finished with '+strpas(TFileName.lpstrFile));
Readln;
End.


On 11/4/2018 11:21 AM, James wrote:
> This is very interesting, thank you for the code on how to define the 
> GetSaveFileNameA function.  I wrote a sample program to get it to work, but I 
> think I have some syntax wrong, or maybe I'm not initializing something 
> correctly.   It compiles ok, but it doesn't execute even my writeln's, I just 
> get an exit code = 1
>
> James
>
> Program TestGetSaveFileNameA;
> Uses CRT,Classes,Sysutils,windows;
> Type
>   TOpenFileNameAHookProc = function(Wnd: HWND; Msg: UINT; wParam: 
> WPARAM;
> lParam: LPARAM): UINT stdcall;
>
>   TOpenFileNameA = Packed Record
>   lStructSize: DWord;
>   hWndOwner: HWND;
>   hInstance: HINST;
>   lpstrFilter: PChar;
>   lpstrCustomFilter: PChar;
>   nMaxCustFilter: DWord;
>   nFilterIndex: DWord;
>   lpstrFile: PChar;
>   nMaxFile: DWord;
>   lpstrFileTitle: PChar;
>   nMaxFileTitle: DWord;
>   lpstrInitialDir: PChar;
>   lpstrTitle: PChar;
>   Flags: DWord;
>   nFileOffset: Word;
>   nFileExtension: Word;
>   lpstrDefExt: PChar;
>   lCustData: LPARAM;
>   lpfnHook: TOpenFileNameAHookProc;
>   lpTemplateName: PChar;
>   lpEditInfo: Pointer;// Undocumented?
>   lpstrPrompt: PChar;
>   _Reserved1: Pointer;
>   _Reserved2: DWord;
>   FlagsEx: DWord;
>   End;
>   POpenFileNameA = ^TOpenFileNameA;
>
> Function GetSaveFileNameA(arg: POpenFileNameA): windows.bool; stdcall; 
> external 'comdlg32' name 'GetSaveFileNameA';
>
> Var
> TFilename  : TOpenFileNameA;
> PFilename  : POpenFileNameA;
>
> Begin
> Writeln('Start');
> TFilename.lpstrInitialDir:=Pchar('I:\');
> Pfilename:=@Tfilename;
> Writeln(GetSaveFileNameA(PFilename));
> Writeln('Finished');
> Readln;
> End.
>
>
>
>
>
> -Original Message-
> From: fpc-pascal  On Behalf 
> Of Ewald
> Sent: Sunday, November 4, 2018 8:06 AM
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] Windows programming tutorials for FPC
>
> On 11/03/2018 09:04 PM, James wrote:
>> So my question is, how can I use Ifilesavedialog with just FreePascal 
>> in a console application?
> First off, the IFileSaveDialog is an interface, not a simple function.
> So, you'll need to:
>   - Include the right units from freepascal (ActiveX and comobj
> IIRC)
>   - Initialize and finalize the COM subsystem (see CoInitialize
> and CoUninitialize)
>   - Use the CoCreateInstance to instantiate an IFileSaveDialog,
> etc.. I've never used the IFileSaveDialog myself, so have a
> look at
> https://msdn.microsoft.com/en-us/library/windows/desktop/bb776913%28v=
> vs.85%29.aspx#usage
>
> That's the nice thing about the GetSaveFileNameA function: one call, 
> and you're done :-)
>
> Now, if this function is n

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-12 Thread James
Thank you!  I somehow missed the result of the function being the status I was 
looking for.   I guess the answer was so easy I couldn't see it 😊 
-Original Message-
From: fpc-pascal  On Behalf Of 
Alexander Grotewohl
Sent: Monday, November 12, 2018 11:10 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

This line:

Writeln(GetSaveFileNameA(@TFilename));

What does it write when you select a file vs when you click x/cancel?
:-):-)

On 11/12/2018 4:31 AM, James wrote:
> I've been using the example below to use the Save-as dialog in my console 
> program, and it works great, but I would like to be able to detect if the 
> user pushes either the red X or the cancel button in the dialog.   I am 
> supplying a suggested default name, and what's happening is if the user 
> cancels or hits the red X, it just saves the file using the suggested default 
> name, but the correct behavior would be to not save anything.   I'm not sure 
> how this is normally done with GetSaveFileNameA.
>
>
> -Original Message-
> From: fpc-pascal  On Behalf 
> Of Alexander Grotewohl
> Sent: Sunday, November 4, 2018 11:48 AM
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] Windows programming tutorials for FPC
>
> Program TestGetSaveFileNameA;
> Uses windows, commdlg;
>
> Var
>  TFilename  : TOpenFileNameA;
>
>  ret: array[0..100] of char;
>
> Begin
>  Writeln('Start');
>
>  fillchar(TFileName, sizeof(TFileName), 0);
>  TFileName.lStructSize:=sizeof(TFileName);
>
>  TFileName.hwndOwner:=0;
>  TFileName.lpstrFile:=ret;
>  TFileName.lpstrFile[0]:=#0;
>  TFileName.lpstrFilter:='Text Files (*.txt)'+#0+'*.txt'+#0;
>  TFileName.nMaxFile:=100;
>  TFileName.Flags := OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_HIDEREADONLY;
>  TFileName.lpstrDefExt:='txt';
>
>  Writeln(GetSaveFileNameA(@TFilename));
>  Writeln('Finished with '+strpas(TFileName.lpstrFile));
>  Readln;
> End.
>
>
> On 11/4/2018 11:21 AM, James wrote:
>> This is very interesting, thank you for the code on how to define the 
>> GetSaveFileNameA function.  I wrote a sample program to get it to work, but 
>> I think I have some syntax wrong, or maybe I'm not initializing something 
>> correctly.   It compiles ok, but it doesn't execute even my writeln's, I 
>> just get an exit code = 1
>>
>> James
>>
>> Program TestGetSaveFileNameA;
>> Uses CRT,Classes,Sysutils,windows;
>> Type
>>  TOpenFileNameAHookProc = function(Wnd: HWND; Msg: UINT; wParam:
>> WPARAM;
>> lParam: LPARAM): UINT stdcall;
>>
>>  TOpenFileNameA = Packed Record
>>  lStructSize: DWord;
>>  hWndOwner: HWND;
>>  hInstance: HINST;
>>  lpstrFilter: PChar;
>>  lpstrCustomFilter: PChar;
>>  nMaxCustFilter: DWord;
>>  nFilterIndex: DWord;
>>  lpstrFile: PChar;
>>  nMaxFile: DWord;
>>  lpstrFileTitle: PChar;
>>  nMaxFileTitle: DWord;
>>  lpstrInitialDir: PChar;
>>  lpstrTitle: PChar;
>>  Flags: DWord;
>>  nFileOffset: Word;
>>  nFileExtension: Word;
>>  lpstrDefExt: PChar;
>>  lCustData: LPARAM;
>>  lpfnHook: TOpenFileNameAHookProc;
>>  lpTemplateName: PChar;
>>  lpEditInfo: Pointer;// Undocumented?
>>  lpstrPrompt: PChar;
>>  _Reserved1: Pointer;
>>  _Reserved2: DWord;
>>  FlagsEx: DWord;
>>  End;
>>  POpenFileNameA = ^TOpenFileNameA;
>>
>> Function GetSaveFileNameA(arg: POpenFileNameA): windows.bool; 
>> stdcall; external 'comdlg32' name 'GetSaveFileNameA';
>>
>> Var
>>  TFilename  : TOpenFileNameA;
>>  PFilename  : POpenFileNameA;
>>
>> Begin
>>  Writeln('Start');
>>  TFilename.lpstrInitialDir:=Pchar('I:\');
>>  Pfilename:=@Tfilename;
>>  Writeln(GetSaveFileNameA(PFilename));
>>  Writeln('Finished');
>>  Readln;
>> End.
>>
>>
>>
>>
>>
>> -Original Message-
>> From: fpc-pascal  On Behalf 
>> Of Ewald
>> Sent: Sunday, November 4, 2018 8:06 AM
>> 

Re: [fpc-pascal] Greetings

2009-04-27 Thread Lou James
I am new here too,I've been using free pascal since a year and a half
ago.And I'm wondering what I can contribute?

On 27/04/2009, Doug Chamberlin  wrote:
> Nino Luciani wrote:
>> Hi guys,
>>
>> A quick introduction. I joined the FPC mailing lists yesterday.
>
> Hi, Nino! Welcome!
>
> Are you new to the Object Pascal world or have you been using the
> language for a while?
>
> Doug C.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


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


[fpc-pascal] -Opentium3 Error

2009-05-09 Thread Lou James
Hi,
 This is a problem troubles me for a long time.You should know I'm a student
in high school and I use Free Pascal to
solve some algorithm problem.
 Sometimes,when I set a new enviroment(school's computer always clean up
after restart)--that is,to set the Properties
of the shortcut "Start In :" option,and type in the folder I want.
 Then,open the shortcut and type in my code.Then, when I try to compile
it,it may popup a error says something about "-opentium3".
And stop compiling.The only way to correct this error seems to be that I
must open the "fp.cfg" file and manually delete all the "-opentium3"
strings in that file.

What caused the problem?
Can we avoid it?

I'm a Chinese high school student and new to this mail-list.
Thanks...



-- 
.樓洵
http://www.AquarHEAD.com 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] -Opentium3 Error

2009-05-09 Thread Lou James
Oh,it seems so
I upgrade my fpc to 2.2.4 in the Ubuntu OS,but forgot windows.
By the way,Win7 RC is great.

2009/5/9 Jonas Maebe 

>
> On 09 May 2009, at 14:44, Lou James wrote:
>
> Then,open the shortcut and type in my code.Then, when I try to compile
>> it,it may popup a error says something about "-opentium3".
>> And stop compiling.The only way to correct this error seems to be that I
>> must open the "fp.cfg" file and manually delete all the "-opentium3"
>> strings in that file.
>>
>> What caused the problem?
>>
>
> A typing error in the default configuration file of the IDE shipped with
> FPC 2.2.2
>
> Can we avoid it?
>>
>
> Install FPC 2.2.4 instead.
>
>
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



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

[fpc-pascal] Question about fcl-image package

2009-07-28 Thread James Buren
I've looked through the source of this thing and the means it has for
scaling an image does not appear to be anti-aliased as I would require for
my usage which is for icon scaling to a consistent dimension. From what I
can tell, a C library called Imlib2 appears to provide what I need, but
fcl-image appears to be preferred over this, but it does not appear to
have everything I need. Am I overlooking a feature in fcl-image that would
give me the scaling quality that I need?

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


Re: [fpc-pascal] C-->Pas translation question

2009-09-08 Thread James Buren
> how to translate following C code to pascal?
>
> enum{IUP_SHOW, IUP_RESTORE, IUP_MINIMIZE, IUP_MAXIMIZE, IUP_HIDE};
>
> thanks
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>

Well, according to what you've shown us, its a C enumeration without a
type name, which means it works the same as #defines more or less. The
best way I can think of is to do:

Const
IUP_SHOW = 0;
...

If I recall, the enumeration starts at 0 in C if its not specified.


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


[fpc-pascal] Questions

2009-09-22 Thread James Buren
I have some questions about the RTL and FPC and how it effects what
license I can use for my source.

1) Does FPC impose any license restrictions for the programs I compile
with it?

2) Does the RTL impose a license restriction if all I do is link my
program to it?

3) Any thing else I should know about the license conditions?

4) Finally, are there any good books or similar that would help with
learning the free pascal implementation of extensions to the original
pascal? All I seem to have to go on is a basic tutorial introduction and
the reference manual for the compiler.

Thank you.

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


Re: [fpc-pascal] Video4Linux access

2009-10-15 Thread James Buren
> Hi Everybody,
>
> I need video4linux support for my new project. I tried vfp unit
> I found in the contribute units website.
> But it seems very outdated. Itried all things menitioned in the
> forum, but I'm not able to get the things up. the code  is hard
> to read and I found not one comment line :(
> Thanks for the hard work, but with some comments i possibly
> would be able to fix broken stuff.
>
> Is there an alternative way to use video4linux ?
>

You could look into the native C API source code, see how its used, and
write a FP binding yourself, perhaps with a C wrapper to boot? I know
mplayer uses it as one of its input drivers. You could take a look around
there to get an idea of how it works.

> Thanks a lot and please use comments ;)
>
> Hartmut
>
> --
> ___
> 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


[fpc-pascal] Streaming classes?

2009-10-19 Thread James Buren
I've encountered this mentioned several times in the documentation but I
have no clue what its used for or why I would want to use it. Is it
talking about reading and writing class information to file, memory,
network streams? If not, then what is this?

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


[fpc-pascal] 'Uses' keyword

2009-10-25 Thread James Buren
Is there any way to get FPC to tell me what units get included when I
include a unit? I'm asking because I'd like to know so I can find out what
units I'm using and what licenses they use so I know what licenses I'm
dealing with so I know how it will effect my program.

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


Re: [fpc-pascal] Free Pascal 2.4.0 released

2010-01-03 Thread Lou James
I still didn't find out where to get the 2.4.0 version for iphone..
Shouldn't it be under ARM/Mac OS X?

-- 
樓洵(AquarHEAD)
--
Blossoms which were the joys that fell,
And leaves, the hopes that yet remain.
--
http://www.AquarHEAD.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Free Pascal 2.4.0 released

2010-01-03 Thread Lou James
Oh I see.
Thanks && Happy New Year!~

2010/1/3 Florian Klaempfl 

> Lou James schrieb:
> > I still didn't find out where to get the 2.4.0 version for iphone..
> > Shouldn't it be under ARM/Mac OS X?
>
> No. The directories are named by host operating system so the arm-macosx
> cross compiler is in
> ftp://ftp.freepascal.org/pub/fpc/dist/2.4.0/i386-macosx/
>  ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



-- 
樓洵(AquarHEAD)
--
Blossoms which were the joys that fell,
And leaves, the hopes that yet remain.
--
http://www.AquarHEAD.com
Sent from Jiamusi, 23, China
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Cancelling Scientific notation

2010-01-25 Thread James Gibbens
Hallo FPC gurus,
I am VERY new to free pascal and I have a couple of problems. Can somebody 
please help?
1. If a, b are real numbers and I want to round a/b foo to 3 decimal places, 
the answer is displayed in Scientific notation. How do I turn that off?
2. Without using Object Pascal, how can I change the background colour, a very 
black BLACK, when the program runs? It is strenuous on my poor eyes.
Thank you so far. The rest of the problems can wait a couple of days.
James Gibbens.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Cancelling Scientific notation

2010-01-26 Thread James Gibbens

Good evening Frank,
Thank you very much for your answer. The Writeln(y:0:2); works beautifully.
The backgroundcolor is solved as far as the text goes, but the rest is still 
black. What is the whole area cover by the program, the "screen" called?

I still need to down load the help files - so if I am stupid, please say so.
I am a retired MAths teacher and I want to make programs so that the 
learners(?) [earlier we called them pupils / students] can PRACTISE the 
Maths.


Thanks again
James

- Original Message - 
From: "Frank Peelo" 

To: "FPC-Pascal users discussions" 
Sent: Monday, January 25, 2010 8:53 PM
Subject: Re: [fpc-pascal] Cancelling Scientific notation



On 25/01/2010 18:37, James Gibbens wrote:

Hallo FPC gurus,
I am VERY new to free pascal and I have a couple of problems. Can 
somebody please help?
1. If a, b are real numbers and I want to round a/b foo to 3 decimal 
places, the answer is displayed in Scientific notation. How do I turn 
that off?


Are you using Write and Writeln? For strings and integers, you can specify 
the field width, e.g.

  x := 'Hello';
  Write(x:10);
will write the variable x using at least 10 characters, using spaces for 
padding if necessary. For floating-point types you can also specify the 
decimal places, e.g.

  y := 12.345;
  Writeln(y:0:2);
will write y using at least 0 characters, i.e. no padding at all, with 2 
digits after the decimal point.


2. Without using Object Pascal, how can I change the background colour, a 
very black BLACK, when the program runs? It is strenuous on my poor eyes.


That I'm not so sure of. There used to be a crt unit, so add CRT to the 
uses clause at the top of your program

uses foo, bar, CRT, whatever;
and then you could use
  textbackground(blue);
  textcolor(yellow);
and like that. I guess it's still supported.

Frank


___
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] Cancelling Scientific notation

2010-02-05 Thread James Gibbens

Hallo all,
Thank you for all the answers I have received.
Some more stupid questions please:
1. How can I get fpc to use a comma (,) in stead of a period (.) as the 
separator between whole number and fraction?
2. The window showing the program listing on the screen is rather mall. How 
do I enlarge it to show more lines? I tried clicking and ragging but nothing 
works.
3. I want to print the program listing. I click on Files, print and nothing 
happens. The device is shaown as lst or prn. How do I fix that?


Thanks again.
James Gibbens





- Original Message - 
From: "Marco van de Voort" 

To: "FPC-Pascal users discussions" 
Sent: Tuesday, January 26, 2010 11:23 PM
Subject: Re: [fpc-pascal] Cancelling Scientific notation



In our previous episode, James Gibbens said:

Good evening Frank,
Thank you very much for your answer. The Writeln(y:0:2); works 
beautifully.
The backgroundcolor is solved as far as the text goes, but the rest is 
still

black. What is the whole area cover by the program, the "screen" called?
I still need to down load the help files - so if I am stupid, please say 
so.

I am a retired MAths teacher and I want to make programs so that the
learners(?) [earlier we called them pupils / students] can PRACTISE the
Maths.


clrscr;

cleans the screen with the currently set fore- and background colors.

___
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


[fpc-pascal] Printing of FPC program listing

2010-02-15 Thread James Gibbens
Hallo All,
Thank you for the answers and advice I have received. Three new issues if you 
good people don't mind.
1. I want to print my program listing by using the print option in the File 
drop-down menu (Free Pascal IDE window). I click on the Print option but 
nothing happens - the printer is on and it does print. How can I fix that?
2. The window of the Free Pascal IDE is only 21 lines high. Is it possible to 
show more lines on the computer screen? How can I do that?
3. Is it possible to get FPC to use a comma (,) in stead of a period (.) as the 
separator between integer and fraction? The way they do it in Europe?
Thank you for the answers.
James Gibbens.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Printing of FPC program listing

2010-02-17 Thread James Gibbens

Thank you - will try
My computer runs on Windows XP.

- Original Message - 
From: "Marco van de Voort" 

To: "FPC-Pascal users discussions" 
Sent: Wednesday, February 17, 2010 11:32 AM
Subject: Re: [fpc-pascal] Printing of FPC program listing



In our previous episode, James Gibbens said:



Thank you for the answers and advice I have received. Three new issues if
you good people don't mind.


Operating system?


1. I want to print my program listing by using the print option in the
File drop-down menu (Free Pascal IDE window).  I click on the Print 
option

but nothing happens - the printer is on and it does print.  How can I fix
that?


2. The window of the Free Pascal IDE is only 21 lines high. Is it 
possible to show more lines on the computer screen? How can I do that?


Enlarge the window before starting. OS? If *nix, try to use a XTerm 
console,

and see if that improves.


3. Is it possible to get FPC to use a comma (,) in stead of a period (.)
as the separator between integer and fraction?  The way they do it in
Europe?


There are some possibilities. In general TP functions don't, and Delphi
functions do honour the locale. Delphi (sysutils) routines often have a
TFormatSettings parameters where you can pass custom locale settings.

Or try setting "decimalseparator" to ','

___
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: Re: [fpc-pascal] Need three things

2007-08-14 Thread James Smith
Real world need for DbC, or some way to show due diligence:

http://www.lightbluetouchpaper.org/2007/08/10/house-of-lords-inquiry-personal-internet-security/

Quote:

"The third area, and this is where the committee has been most far-sighted, and 
therefore in the short term this may well be their most controversial 
recommendation, is that they wish to see a software liability regime, viz: that 
software companies should become responsible for their security failures.

"and in practice it may be a decade or two before there’s sufficient case law 
for vendors to know quite where they stand if they ship a product with a buffer 
overflow, or a race condition, or just a default password"

Competitive advantage to be exploited here.

James

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


Re: [fpc-pascal] Competitive advantage in showing proof of correctness

2007-08-14 Thread James Smith

There's a company already doing that:



http://www.praxis-his.com/sparkada/intro.asp


I've read their book. Cool stuff.

James


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


Re: [fpc-pascal] Competitive advantage in showing proof of correctness

2007-08-14 Thread James Smith

Let's first get people of type unsafe languages. Type safety with range

checking etc. are a big improvement over type unsafe languages. Yes,
Pascal is already the language to use if you are interrested in software
correctness.


And perhaps Tom Verhoeff's work will lead to contract programming. But I

don't believe it will be a requirement for FPC, as after decades, very few
people have an interrest in correctness of their programs. Lastly, pre and
post conditions are just another runtime check. Checks can be used to show
the existance of bugs, but not their absence.

Well, I know programmers who turn off range checking and let exceptions fall 
through empty exception blocks. They don't work with me on projects. My 
guess is that this is a business issue that will be decided for programmers, 
not by programmers. Additionally, it's not an issue of absolutes, but of due 
diligence. Once the bar is raised on what due diligence means for software 
developers, they'll accept it because they have to.


Before completely dismissing this issue, I hope you guys will consider 
merging Tom's qualified work into the trunk at some point.


James


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


Re: [fpc-pascal] Competitive advantage in showing proof of correctness

2007-08-14 Thread James Smith

Of course it will be considered. I don't think we are there yet though.

First, Tom needs to say he is ready for merging though. Second we need to
do some peer review on the code. However, I don't think anyone in the team
is again his work.

Excellent, thanks Daniël.

James



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


[fpc-pascal]Dynamic Arrays (Pointers)

2003-01-24 Thread James Mills
Hi,

I'm using FPC 1.0.4

Would someone be so kind as to show me an example of using dynamic
arrays of an object, creating new objects on the fly in code and
disposing of them when they're no longer needed. Use of this would be in
a irc services program I'm porting to linux from delphi (windows), ie:
new nick joins server, create new object respresenting that nick...

Thank you
James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]FPC vs. GPC (was:FPC 1.0.6 and open arrays)

2003-01-28 Thread James Mills
On Tue, Jan 28, 2003 at 12:05:28PM +0100, Andreas K. Foerster wrote:
> On Mon, Jan 27, 2003 at 10:42:37PM +0100, Marco van de Voort wrote:
> 
> > > Will there also be sopport for conformant Arrays as they are defined 
> > > in standard Pascal (ISO-7185)?
> > 
> > Not that I'm aware of (unless you plan to implement it ? ).
> 
> No, I can't do it.
> 
> The point is just, that I'm still disappointed that FPC isn't
> compatible to any of the official Pascal standards and that it's not
> even trying to become compatible.
> 
> I'm very much drawn back and forth between FreePascal and GNU Pascal.
> Both have their advantages, but also their disadvantages. FreePascal
> has more commands, but GNU Pascal knows a much more elaborated syntax.
> FreePascal supports just one dialect, GNU Pascal knows different
> dialects including the standards. FreePascal has lots of systemspecific
> extentions, but programs written with them aren't portable,
> even not between the different variants of FreePascal itself. 
> GNU Pascal tries to leave systemspecific things away, that means that
> programs are nearly always portable, but also that things are missing.
> GNU Pascal (the compiler itself) is very portable, while FreePascal is 
> mainly targeted to PCs and porting to other platforms seems to take a
> lot of time. On the other hand GNU Pascal is hard to install, 
> especially on non-Unix systems. GNU Pascal is the better Pascal, when 
> you look at the source code of your programming, but FreePascal is the 
> better compiler, when you look at the binary that comes out...
>   
> What I really want would be a mixture of both!
> 
> At the moment I try to use only what both have in common. But
> unfortunately that's not much. I have to avoid commands because of
> GPC and I have to use a simpler syntax because of FPC.
> 
> That's why I try to suggest that FPC should become more standard
> compatible, to be able to write more portable code. 
> 
> Okay, I see that it's difficult to implement.
> But what about things that look similar? 
> 
> For example initialized variables...
> 
> FPC has this syntax:
> const i: integer = 0;
> But it's so very unlogical to use a "const" as variable. :-(
> (GPC accepts this syntax, but gives a warning)
> 
> Extended Pascal (ISO-10206) declares this syntax:
> var i: integer value 0;
> Much nicer, isn't it?
> 
> That at least looks very similar so I hope, at least that will be
> simpler for you to implement...
> 
> BTW. you might wonder why Extended Pascal uses "value" and not the
> equal-sign. That is because it also defines initialized types:
> type myint = integer value 0;
> so that all variables that use this type are initialized.
> Here a second equal-sign would look strange.
> 
> Or what about String definitions:
> FPC: 
> var s: string[255];
> ISO-10206:
> var s: string(255);  {btw. not limited to 255}
> Would it be so difficult to accept parantheses instead of brackets?
> GPC accepts both.
Try writing a compiler first instead of complaining about FPC's syntax
:)

You are toying with the issue of syntax. There is nothing wrong with
FPC's syntax, it's quite compatible with standard pascal and I disagree
with most of what you say above. FPC to my knowledge was created as an
alternative to Borland Pascal which only supported the 16-bit PC
architecture. We need a pascal compiler to support 32bit.

> FPC has this syntax:
> const i: integer = 0;
> But it's so very unlogical to use a "const" as variable. :-(
> (GPC accepts this syntax, but gives a warning)

What on earth would we want a more typed language ? Pascal is stongly
typed enough as it is, and is quite comfortable to use. People like
myself that have been using pascal for many many years will not be happy
to find that pascal now has a new syntax.

cheers
James

> 
> -- 
> Tschuess
>   Andreas
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



[fpc-pascal]1.0.6 problem

2003-02-03 Thread James Mills
Hi all,

I just recently upgraded to FPC 1.0.6 (Debian testing-SID), one of my
programs now doesn't compile because of this error.

functions.pas(42,2) Error: Incompatible types: got "" expected 
""

Here is the source pertaining to it:

{ Function Declarations }
function SignOf(args: pString; argCount: longInt): String;
function GetTimeOf(args: pString; argCount: longInt): String;
function TimeStamp(args: pString; argCount: longInt): String;
function Rnd(args: pString; argCount: longInt): String;
function AbsOf(args: pString; argCount: longInt): String;
function Ans(args: pString; argCount: longInt): String;
function Pow(args: pString; argCount: longInt): String;
function Duration(args: pString; argCount: longInt): String;
function Len(args: pString; argCount: longInt): String;
function Sigma(args: pString; argCount: longInt): String;
function IntOf(args: pString; argCount: longInt): String;
function FracOf(args: pString; argCount: longInt): String;
function nPr(args: pString; argCount: longInt): String;
function nCr(args: pString; argCount: longInt): String;
function getPI(args: pString; argCount: longInt): String;
function e(args: pString; argCount: longInt): String;
function sine(args: pString; argCount: longInt): String;
function cosine(args: pString; argCount: longInt): String;
function tangent(args: pString; argCount: longInt): String;
function arcsine(args: pString; argCount: longInt): String;
function arctangent(args: pString; argCount: longInt): String;
function Modulas(args: pString; argCount: longInt): String;
function SqrRoot(args: pString; argCount: longInt): String;
function RoundNumber(args: pString; argCount: longInt): String;
function TruncateNumber(args: pString; argCount: longInt): String;
function Radians(args: pString; argCount: longInt): String;
function Degrees(args: pString; argCount: longInt): String;

const NumFunctions = 27;

const FunctionsTable: Array[0..(NumFunctions - 1)] of function(args:
pString; argCount: longInt): String = (
   SignOf,
   GetTimeOf,
   TimeStamp,
   Rnd,
   AbsOf,
   Ans,
   Pow,
   Duration,
   Len,
   Sigma,
   IntOf,
   FracOf,
   nPr,
   nCr,
   getPI,
   e,
   sine,
   cosine,
   tangent,
   arcsine,
   arctangent,
   Modulas,
   SqrRoot,
   RoundNumber,
   TruncateNumber,
   Radians,
   Degrees
);

Could someone help me out here please, as it did compile with 1.0.4

thank you :)

James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]1.0.6 problem

2003-02-03 Thread James Mills
On Mon, Feb 03, 2003 at 01:37:34PM +0100, Jonas Maebe wrote:
> 
> On maandag, feb 3, 2003, at 13:24 Europe/Brussels, James Mills wrote:
> 
> >I just recently upgraded to FPC 1.0.6 (Debian testing-SID), one of my
> >programs now doesn't compile because of this error.
> >
> >functions.pas(42,2) Error: Incompatible types: got "" 
> >expected " >function(PSTRING,LONGINT):AnsiString;>"
> 
> The reason that it compiled in 1.0.4, was a bug in that version of the 
> compiler. You can compile this code as-is in TP or Delphi mode. In FPC 
> or ObjFPC mode, you have to add an "@" in front of the procedure names 
> to get their addresses. In version 1.0.4, this extra @ in FPC mode was 
> already enforced in normal code, but not in typed constants. This 
> inconsistency was fixed in 1.0.6.

Ok thank you. I know it was inconsistant in 1.0.4, but ignored it as it
did compile properly ;) I would have spent ages figuring this out had
you not said it was an inconsistancy with 1.0.4. Thank you.

cheers
James
> 
> 
> Jonas
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Performance testing of FPC programs?

2003-02-07 Thread James Mills
On Fri, Feb 07, 2003 at 04:56:10PM +0100, Preben Mikael Bohn wrote:
> Hi all, I have a relatively large FPC program that I suspect have a few
> bottlenecks (regarding processing speed). Are there any ways I can test how
> long time the program spends in the different procedures/functions?

Use this bit of code in your functions/procedures or write it as a
function and call it.


> 
> Best regards Preben
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Program Example5;

{ Program to demonstrate the GetTime function. }

Uses linux, CRT, sysUtils;

Var Hour, Minute, Second, msec, usec : Word;

begin
	clrScr;
	repeat
		gotoXY(1, 1);
  		getTime (Hour, Minute, Second, msec, usec);
		writeLn('Time: ' + intToStr(Hour) + ':' + intToStr(Minute) + ':' + intToStr(Second) + '.' + intToStr(msec) + '.' + intToStr(usec));
	until keyPressed;
end.



[fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
Hi all,

Sorry if this is trivial, but I'm sick of it :)
I'm using fpc to convert my (originally delphi) code to read and write
ini style files, however writing will not work as I want, the data in
the pointer keeps getting filled with junk.

I'm using getMem, and reAllocMem functions to create dynamic arrays of
strings. The writeINI function reads the entire file in, but doesn't
even do that correctly.

I have a test program that uses the same idea, and it works perfectly,
so I'm very bewildered :(

attached is the code if someone would like to have a look at it, please.

thank you
James

unit iniFiles;

interface

uses
	sysUtils, tokenizerClass;

type
	pString = ^String;

procedure writeINI(fileName: String; section: String; ident: String; value: String);
function readINI(fileName: String; section: String; ident: String; default: String): String;

implementation

procedure writeINI(fileName: String; section: String; ident: String; value: String);
var
	tmpStrings:		pString;
	inputFile:		Text;
	outputFile:		Text;
	I:	Integer;
	X:	Integer;
	C:	Integer;
	temp:String;
	foundSection:	Boolean;
	foundIdent:		Boolean;
	tmpIdent:		String;
	inserted:		String;
	tokens:			PTokenizer;
begin
	foundSection := FALSE;
	foundIdent := FALSE;
	if NOT fileExists(fileName) then
		begin
			assign(outputFile, fileName);
			rewrite(outputFile);
			writeLn(outputFile, #91 + section + #93);
			writeLn(outputFile, ident + #61 + value);
			close(outputFile);
		end
	else
		begin
			I := 0;
			getMem(tmpStrings, 100);
			assign(inputFile, fileName);
			reset(inputFile);
			while NOT EOF(inputFile) do
begin
	{reAllocMem(tmpStrings, (I + 1));}
	readLn(inputFile, tmpStrings[I]);
	inc(I);
end;
			close(inputFile);
			C := (I - 1);

			for I := 0 to C do
begin
	writeLn(intToStr(I) + ': ' + tmpStrings[I]);
end;

			for I := 0 to C do
begin
	if tmpStrings[I] = (#91 + section + #93) then
		begin
			foundSection := TRUE;
			break;
		end;
end;

			if foundSection then
begin
	writeLn('Found section at line ' + intToStr(I));

	for X := (I + 1) to C do
		begin
			if length(tmpStrings[X]) >= 1 then
begin
	if (tmpStrings[X])[1] = #91 then
		begin
			break;
		end;
end;
		end;

	writeLn('Section ranges from ' + intToStr(I) + ' to ' + intToStr(X));

	for I := I to X do
		begin
			tokens := new(PTokenizer, init(tmpStrings[I], '='));
			tmpIdent := tokens^.nextToken;
			dispose(tokens, deInit);

			if tmpIdent = ident then
begin
	foundIdent := TRUE;
	break;
end;
		end;

	if foundIdent then
		begin
			writeLn('Found ident at line ' + intToStr(I));

			tmpStrings[I] := ident + #61 + value;
			inserted := '';
			X := -1;
		end
	else
		begin
			inserted := ident + #61 + value;
		end;
end
			else
begin
	inc(C, 2);
	reAllocMem(tmpStrings, C);
	tmpStrings[I + 1] := (#91 + section + #93);
	tmpStrings[I + 2] := (ident + #61 + value);
end;

			assign(outputFile, fileName);
			rewrite(outputFile);

			for I := 0 to C do
begin
	if I = X then
		begin
			writeLn(outputFile, tmpStrings[I]);
			writeLn(outputFile, inserted);
		end
	else
		begin
			writeLn(outputFile, tmpStrings[I]);
		end;
end;

			close(outputFile);

			freeMem(tmpStrings, 0);
		end;
end;

function readINI(fileName: String; section: String; ident: String; default: String): String;
var
	f:	Text;
	temp:String;
	foundSection:	Boolean;
	tokens:			PTokenizer;
	tmpIdent:		String;
	tmpValue:		String;
begin
	readINI := default;
	foundSection := FALSE;
	if fileExists(fileName) then
		begin
			assign(f, fileName);
			reset(f);
			
			while NOT EOF(f) do
begin
	readLn(f, temp);
	if NOT foundSection then
		begin
			if upperCase(temp) = upperCase((#91 + section + #93)) then
begin
	foundSection := TRUE;
end;
		end
	else
		begin
			if NOT (temp = '') then
begin
	if temp[1] = #91 then
		begin
			break;
		end;

	tmpIdent := '';
	tmpValue := '';
	tokens := new(PTokenizer, init(temp, '='));
	tmpIdent := tokens^.nextToken;
	tmpValue := tokens^.nextToken;
	dispose(tokens, deInit);

	if upperCase(tmpIdent) = upperCase(ident) then
		begin
			if tmpValue = '' then
begin
	break;
end
			else
begin
	readINI := tmpValue;
	break;
end;
		end;
end;
		end;
end;
			close(f);
		end;
end;

end.

program test;

uses
	iniFiles;

var
	fileName:	String;
	section:		String;
	iden

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 08:30:57PM +1000, James Mills wrote:
> Hi all,
> 
> Sorry if this is trivial, but I'm sick of it :)
> I'm using fpc to convert my (originally delphi) code to read and write
> ini style files, however writing will not work as I want, the data in
> the pointer keeps getting filled with junk.
> 
> I'm using getMem, and reAllocMem functions to create dynamic arrays of
> strings. The writeINI function reads the entire file in, but doesn't
> even do that correctly.
> 
> I have a test program that uses the same idea, and it works perfectly,
> so I'm very bewildered :(
> 
> attached is the code if someone would like to have a look at it, please.
> 
> thank you
> James

Sorry, forgot to include the tokenizerclass.pas

cheers
James

unit tokenizerClass;

interface

type
	TTokenizer = object
		constructor init(tmpStr: String);
		constructor init(tmpStr: String; tmpDelim: Char);
		destructor deInit;
		private
			str:		String;
			token:	String;
			num:		Integer;

			delim:	Char;

			function countTokens: Integer;
		public
			function nextToken: String;
			function numTokens: Integer;
			function restOfTokens: String;
	end;
	PTokenizer = ^TTokenizer;

implementation

constructor TTokenizer.init(tmpStr: String);
begin
	delim := ' ';
	if tmpStr = '' then
		begin
			str := '';
			num := 0;
		end
	else
		begin
			str := tmpStr;
			num := countTokens;
		end;
end;

constructor TTokenizer.init(tmpStr: String; tmpDelim: Char);
begin
	delim := tmpDelim;
	if tmpStr = '' then
		begin
			str := '';
			num := 0;
		end
	else
		begin
			str := tmpStr;
			num := countTokens;
		end;
end;

destructor TTokenizer.deInit;
begin

end;

function TTokenizer.countTokens: Integer;
var
	i:	Integer;
	c:	Integer;
begin
	c := 0;
	for i := 1 to length(str) do
		begin
			if str[i] = delim then
begin
	inc(c);
end;
		end;
	countTokens := (c + 1);
end;

function TTokenizer.nextToken: String;
var
	i:	Integer;
begin
	i := pos(delim, str);
	if i > 0 then
		begin
			token := copy(str, 1, (i - 1));
			str := copy(str, (i + 1), length(str));
		end
	else
		begin
			token := str;
			str := '';
		end;
	dec(num);
	nextToken := token;
end;

function TTokenizer.numTokens: Integer;
begin
	numTokens := num;
end;

function TTokenizer.restOfTokens: String;
begin
	restOfTokens := str;
	str := '';
	num := 0;
end;

end.



Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 02:22:55PM +0100, Anton Tichawa wrote:
> Hello, James!
> 
> I found an error at GetMem / ReAllocMem: Your code:
> 
>   getMem(tmpStrings, 100);
>   {reAllocMem(tmpStrings, (I + 1));}
> 
> reserves 100 or (I + 1) BYTES, but you need space for 100 or (I + 1) 
> STRINGS, i. e. the code should be:
> 
>   getMem(tmpStrings, SizeOf(String) * 100);
>   {reAllocMem(tmpStrings, SizeOf(String) * (I + 1));}
> 
> Even then, I don't know if fpc behaves correctly converning deallocation when 
>  defaults to . Maybe somebody else can respond to this?
> 
> Another note: Please replace tabulators by spaces when posting code.
> 
> Hope this Helps.
> 
> Anton Tichawa.

Thank you, I"ll try that.

> 
> 
> 
> On Sunday 09 February 2003 11:30, you wrote:
> > Hi all,
> >
> > Sorry if this is trivial, but I'm sick of it :)
> > I'm using fpc to convert my (originally delphi) code to read and write
> > ini style files, however writing will not work as I want, the data in
> > the pointer keeps getting filled with junk.
> >
> > I'm using getMem, and reAllocMem functions to create dynamic arrays of
> > strings. The writeINI function reads the entire file in, but doesn't
> > even do that correctly.
> >
> > I have a test program that uses the same idea, and it works perfectly,
> > so I'm very bewildered :(
> >
> > attached is the code if someone would like to have a look at it, please.
> >
> > thank you
> > James
> 
> 
> 
> --
> 
> "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte 
> Berechnungen einzuweben."
> 
> Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
> 
> --
> 
> Anton Tichawa
> Volkertstrasse 19 / 20
> A-1020 Wien
> mobil: +43 664 52 07 907
> email: [EMAIL PROTECTED]
> 
> --
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 02:22:55PM +0100, Anton Tichawa wrote:
> Hello, James!
> 
> I found an error at GetMem / ReAllocMem: Your code:
> 
>   getMem(tmpStrings, 100);
>   {reAllocMem(tmpStrings, (I + 1));}
> 
> reserves 100 or (I + 1) BYTES, but you need space for 100 or (I + 1) 
> STRINGS, i. e. the code should be:
> 
>   getMem(tmpStrings, SizeOf(String) * 100);
>   {reAllocMem(tmpStrings, SizeOf(String) * (I + 1));}
> 
> Even then, I don't know if fpc behaves correctly converning deallocation when 
>  defaults to . Maybe somebody else can respond to this?
> 
> Another note: Please replace tabulators by spaces when posting code.
> 
> Hope this Helps.
> 
> Anton Tichawa.

Thank you, it works very well now that I understand how them damn
pointers work. One question though, how do you free the pointer's
memory?

freeMem(tmpStrings, sizeOf(String) * (N));

cheers
James
> 
> 
> 
> On Sunday 09 February 2003 11:30, you wrote:
> > Hi all,
> >
> > Sorry if this is trivial, but I'm sick of it :)
> > I'm using fpc to convert my (originally delphi) code to read and write
> > ini style files, however writing will not work as I want, the data in
> > the pointer keeps getting filled with junk.
> >
> > I'm using getMem, and reAllocMem functions to create dynamic arrays of
> > strings. The writeINI function reads the entire file in, but doesn't
> > even do that correctly.
> >
> > I have a test program that uses the same idea, and it works perfectly,
> > so I'm very bewildered :(
> >
> > attached is the code if someone would like to have a look at it, please.
> >
> > thank you
> > James
> 
> 
> 
> --
> 
> "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte 
> Berechnungen einzuweben."
> 
> Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
> 
> --
> 
> Anton Tichawa
> Volkertstrasse 19 / 20
> A-1020 Wien
> mobil: +43 664 52 07 907
> email: [EMAIL PROTECTED]
> 
> --
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 03:12:07PM +0100, Anton Tichawa wrote:
> On Sunday 09 February 2003 12:54, you wrote:
> 
> > freeMem(tmpStrings, sizeOf(String) * (N));
> 
> No, only:
> 
> freeMem(tmpStrings);

But getMem and reAllocMem allocate a number of bytes on the heap,
wouldn't you have to free that number of bytes using freeMem(pointer, n)
?

cheers
James

Btw, I'm using short strings, so I think it'll be ok for now...

> 
> Read the Manual - Free Pascal Programmer's Manual, Section 4.5, "Writing Your 
> Own Memory Manager" - because that's what you're actually doing.
> 
> HTH
> 
> Anton Tichawa.
> 
> 
> 
> --
> 
> "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte 
> Berechnungen einzuweben."
> 
> Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
> 
> --
> 
> Anton Tichawa
> Volkertstrasse 19 / 20
> A-1020 Wien
> mobil: +43 664 52 07 907
> email: [EMAIL PROTECTED]
> 
> --
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 03:42:29PM +0100, Anton Tichawa wrote:
> Hi,
> 
> > But getMem and reAllocMem allocate a number of bytes on the heap,
> > wouldn't you have to free that number of bytes using freeMem(pointer, n)
> > ?
> 
> No, Free Pascal keeps track of the allocated size for a pointer created with 
> GetMem/ReallocMem. They need this information for heap management, so it's a 
> good think to use this information to save one procedure parameter, which is 
> a lot. If you want to determine the number of bytes to deallocate, you may do 
> this by using:
> 
>   Function FreeMemSize(var p:pointer;Size:Longint):Longint;
> 
> Definition:
> FreememSize
> This function should release the memory pointed to by P. The argument Size is 
> the expected size of the memory block pointed to by P. This should be 
> disregarded, but can be used to check the behaviour of the program. 
> 
> I think with FreeMemSize you may corrput the heap, so be careful with it!
> 
> Anton.

Ok thank you very muchly :) You've been a great help.

> 
> 
> >
> > Btw, I'm using short strings, so I think it'll be ok for now...
> >
> > > Read the Manual - Free Pascal Programmer's Manual, Section 4.5, "Writing
> > > Your Own Memory Manager" - because that's what you're actually doing.
> > >
> > > HTH
> > >
> > > Anton Tichawa.
> > >
> > >
> > >
> > > --
> > >
> > > "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte
> > > Berechnungen einzuweben."
> > >
> > > Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
> > >
> > > --
> > >
> > > Anton Tichawa
> > > Volkertstrasse 19 / 20
> > > A-1020 Wien
> > > mobil: +43 664 52 07 907
> > > email: [EMAIL PROTECTED]
> > >
> > > --
> > > ___
> > > fpc-pascal maillist  -  [EMAIL PROTECTED]
> > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> >
> > ___
> > fpc-pascal maillist  -  [EMAIL PROTECTED]
> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 
> -- 
> 
> --
> 
> "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte 
> Berechnungen einzuweben."
> 
> Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
> 
> --
> 
> Anton Tichawa
> Volkertstrasse 19 / 20
> A-1020 Wien
> mobil: +43 664 52 07 907
> email: [EMAIL PROTECTED]
> 
> --
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



[fpc-pascal]Classes/Objects/Pointers

2003-02-09 Thread James Mills
Hi all,

Sorry to bother you again, can't seem to see what I'm doing wrong it's
the same as my dynamic code for strings...

var
   nicks:   PNick;
   nNicks:  Integer;

procedure initialiseDataNicks;

procedure addNick(data: String);
procedure updateNick(index: Integer; nick: pNick);
function getNick(nick: String; var index: Integer): pNick;
procedure delNick(nick: String);

implementation

procedure initialiseDataNicks;
begin
   nNicks := 0;
end;

procedure addNick(data: String);
var
   tokens:  PTokenizer;
   nick:String;
   hops:Integer;
   signon:  longInt;
   ident:   String;
   host:String;
   server:  String;
   unused:  String;
   name:String;
begin
   tokens := new(PTokenizer, init(data));

   nick := tokens^.nextToken;
   hops := strToInt(tokens^.nextToken);
   signon := strToInt(tokens^.nextToken);
   ident := tokens^.nextToken;
   host := tokens^.nextToken;
   server := tokens^.nextToken;
   unused := tokens^.nextToken;
   name := tokens^.nextToken;

   getMem(nicks, sizeOf(TNick) * nNicks);
50:   nicks := new(PNick, init(nick, hops, signon, ident, host, server, unused, name));
   inc(nNicks);

   dispose(tokens, deInit);
end;


...

$ fpc datanicks.pas 
Free Pascal Compiler version 1.0.6 [2002/08/10] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling datanicks.pas
datanicks.pas(50,19) Error: Incompatible types: got "PNICK" expected
"TNICK"
datanicks.pas(58,16) Error: Illegal qualifier
datanicks.pas(58,25) Error: Illegal qualifier
datanicks.pas(67,26) Error: Illegal qualifier
datanicks.pas(70,26) Error: Illegal qualifier
datanicks.pas(83,31) Error: Illegal qualifier
datanicks.pas(100) Fatal: There were 6 errors compiling module, stopping

If I can fix that error at line 50, I'm sure I can fix the others.
Obviously trying to create arrays of type TNick on the fly, but am a
little confused here...

thanks for your help
James

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Classes/Objects/Pointers / Pointer Help

2003-02-10 Thread James Mills
On Mon, Feb 10, 2003 at 01:24:05PM +0100, Anton Tichawa wrote:
> Hello!
> 
> If TNick is a class - I don't have the declarations - it must be initialized 
> with
> 
>   nicks := new(TNick, init(nick, hops, signon, ident, host, server, unused,   
>   name));
> 
> That's correct because TNick is already a pointer, not an object, and init is 
> required to call TNick's constructor.
> 
> But the problem ist a more generic one .. I'll try to formulate the 
> questions: A procedure (Alice) passes Data to another procedure (Bob):

So you say I should be using class declarations instead of object ?
Fair enough if that's the case, but could you show a simple example that
uses just object declarations ?

ie:

type
   TmyObject = object
  constructor init;
  destructor deInit;
  private
  public
 procedure test;
   end;
   PmyObject = ^TmyObject;

procedure TmyObject.test;
begin
   writeLn('test');
end;

...

James

> 
> ***
> procedure Alice;
> begin
>   Bob(Data);
> end;
> ***
> 
> Questions:
> 
> 1. is Data "empty", i. e. is the call to Bob parameterless? Note that even in 
> this case, there is still information flow between them, because 1. Bob knows 
> having been called by Alice (which is information > 0 bit), and 2. might read 
> input and return results in a predefined, global manner.
> 
> 2. is Data readable?
> 
> 3. is it writeable?
> 
> 4. is it a special (CPU, hardwre) register, or global memory?
> 
> 5. Is Data the only one of it's kind, or does it need addressing? If it needs 
> addressing, is the address defined? Does Data have a fixed size? If not, is 
> the size known or unknown?
> 
> 6. Other questions that I don't see at the moment. One of these is the SWITCH 
> mentioned below.
> 
> 7. Is Data a pointer? If this is the case, then pointer types should be able 
> to point to "null", "readable", "writeable", "register / memory", and other.
> 
> I think the solution isa kindof redundancy. As a legacy example, look at 
> pointers: Pointers with value $ are defined as "nil". That disallows 
> pointing to a variable at address 0. On one hand, that excludes memory at 
> address 0 to be used for "pointed-to" data. On the other hand, low-level 
> access with references to address 0 might still be required in some cases, 
> simply to increase performance.
> 
> There should be some kind of aggreement about Data. As a second example, 
> Classes e. g. are now checked (the VMT contains a kind of checksum), but this 
> is dangerous for every-day run-time type information, because a pice of 
> arbitrary data might contain a correct checksum, thus pretending to be a 
> class .. trak! exception.
> 
> I suggest the words "SAFE" and "FAST" for these two "modes of operation".
> 
> SAFE mode obeys legacy agreements, forces redundancy, and Bob is guaranteed 
> to find a solution for the questions mentioned above, converning Data. In 
> case of misunderstandings, exception handling moves the system to the safe 
> side.
> 
> In FAST mode, there is no redundancy, i. e. hardware runs at full speed, but 
> software might crash.
> 
> I suggest a BIG RED SWITCH on top / front of the computer, which is normally 
> switched OFF, forcing SAFE mode, disallowing references to address 0 with a 
> pointer, requiring action to follow previous negotiations.
> 
> Any ideas how to continue this topic?
> 
> Anton Tichawa.
> 
> 
> 
> --
> 
> "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte 
> Berechnungen einzuweben."
> 
> Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
> 
> --
> 
> Anton Tichawa
> Volkertstrasse 19 / 20
> A-1020 Wien
> mobil: +43 664 52 07 907
> email: [EMAIL PROTECTED]
> 
> --
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Classes/Objects/Pointers / Pointer Help

2003-02-10 Thread James Mills
On Mon, Feb 10, 2003 at 03:55:45PM +0100, Anton Tichawa wrote:
> Hello, James!
> 
> Personally, I would prefer an even simpler way - but that depends on the 
> future development and backwards compatibility of Free Pascal. Basically, the 
> first step towards objects is ENCAPSULATION, which is PURE SYTNAX, i. e. 
> there are no constructors / destructors required. Your example, including a 
> procedure "main" actually using the object would then be:
> 
> ***
> type TmyObject = object
>   procedure test;
> end;
> 
> procedure TmyObject.test;
> begin
> ? ?writeLn('test');
> end;
> 
> procedure main;
> var
>   MyObject: TmyObject;
> begin
>   MyObject.Test;
> end;
> ***
> 
> That's all. Next question?

Yes ok, fair enough, this much is in my knowledge of Pascal :) hehe, but
the real question is, how do you create these objects on the fly in a
program, ie: dynamic array...
I have tried using plain objects, and have failed in frustration. When
you suggested using classes, it worked right away (of course :P).

cheers
James

> 
> HTH
> 
> Anton Tichawa.
> 
> --
> 
> "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte 
> Berechnungen einzuweben."
> 
> Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
> 
> --
> 
> Anton Tichawa
> Volkertstrasse 19 / 20
> A-1020 Wien
> mobil: +43 664 52 07 907
> email: [EMAIL PROTECTED]
> 
> --
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Classes/Objects/Pointers / Pointer Help

2003-02-10 Thread James Mills
On Mon, Feb 10, 2003 at 01:10:41PM -, Matt D. Emson wrote:
> James,
> 
> One important question... If you are using Delphi source (as you implied
> in the pointers thread), why use Turbo Pascal style objects in your
> conversion? If you used classes, it would be much easier on yourself. No
> pointer notation needed etc, could use the Tinifile class (I assume this
> is in the classes unit of RTL/FCL.) You seem to be beating your head
> with a rock, just to use obsolete (as Borland sees it) syntax.

No I've been using FPC all along, haven't touched Delphi in years since
I moved to Debian Linux. (Hate windoze :P hehe). But I'd still like to
know how it's done the (obsolete way)...

cheers
James

Using classes now does work and works nicely, however the documentation
doesn't say what the default constructor and destructors are

> 
> Matt
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



[fpc-pascal]FPC Problem with reAllocMem...

2003-02-10 Thread James Mills
Hi all,

I've annoyed you guys enough with pointers, objects and clases :P I'm
sorry :)

This bugs me though as to why this program crashes at the 4th call to
addNick(nick: String);

Here is the gdb results, and attached is the source code if anyone is
willing to have a look.

thank you very much :)

James

$ gdb datatest
gdb: Symbol `emacs_ctlx_keymap' has different size in shared object, consider 
re-linking
GNU gdb 2002-04-01-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...
(gdb) break datanicks.pas:47
Breakpoint 1 at $8058f2d: file datanicks.pas, line 47.
(gdb) run
Starting program: /home/pircsrv/src/test/datanicks/datatest 
sizeOf(TNick) = 4
Memory available before getMem: 261856
Memory available after getMem: 261840
Command: a
Nick to add: prologic 1 1044896365 prologic daisy test.prologitech.com 0 :ProLogiTech 
(www.prologitech.com)

Breakpoint 1, ADDNICK (valDATA='prologic 1 1044896365 prologic daisy 
test.prologitech.com 0 :ProLogiTech (www.prologitech.com)')
at datanicks.pas:47
47  MM := memAvail;
(gdb) c
Continuing.
Memory available before addNick: 261792
string = prologic 1 1044896365 prologic daisy test.prologitech.com 0 :ProLogiTech 
(www.prologitech.com)
num tokens = 9
ll is well in FPC
Memory available after addNick: 259680
Command: a
Nick to add: prologic 1 1044896365 prologic daisy test.prologitech.com 0 :ProLogiTech 
(www.prologitech.com)

Breakpoint 1, ADDNICK (valDATA='prologic 1 1044896365 prologic daisy 
test.prologitech.com 0 :ProLogiTech (www.prologitech.com)')
at datanicks.pas:47
47  MM := memAvail;
(gdb) c
Continuing.
Memory available before addNick: 259712
string = prologic 1 1044896365 prologic daisy test.prologitech.com 0 :ProLogiTech 
(www.prologitech.com)
num tokens = 9
All is well in FPC
Memory available after addNick: 257600
Command: a
Nick to add: prologic 1 1044896365 prologic daisy test.prologitech.com 0 :ProLogiTech 
(www.prologitech.com)

Breakpoint 1, ADDNICK (valDATA='prologic 1 1044896365 prologic daisy 
test.prologitech.com 0 :ProLogiTech (www.prologitech.com)')
at datanicks.pas:47
47  MM := memAvail;
(gdb) c
Continuing.
Memory available before addNick: 257632
string = prologic 1 1044896365 prologic daisy test.prologitech.com 0 :ProLogiTech 
(www.prologitech.com)
num tokens = 9
All is well in FPC
Memory available after addNick: 255520
Command: a
Nick to add: prologic 1 1044896365 prologic daisy test.prologitech.com 0 :ProLogiTech 
(www.prologitech.com)

Breakpoint 1, ADDNICK (valDATA='prologic 1 1044896365 prologic daisy 
test.prologitech.com 0 :ProLogiTech (www.prologitech.com)')
at datanicks.pas:47
47  MM := memAvail;
(gdb) c
Continuing.
Memory available before addNick: 22
string = prologic 1 1044896365 prologic daisy test.prologitech.com 0 :ProLogiTech 
(www.prologitech.com)
num tokens = 9

Program received signal SIGSEGV, Segmentation fault.
$08062697 in _SYSLINUX ()
(gdb) bt
#0  $08062697 in _SYSLINUX ()
#1  $080628ab in _SYSLINUX ()
#2  $08061f23 in _SYSLINUX ()
#3  $080591c6 in ADDNICK (valDATA='prologic 1 1044896365 prologic daisy 
test.prologitech.com 0 :ProLogiTech (www.prologitech.com)')
at datanicks.pas:66
#4  $08065b17 in main () at datatest.pas:21
(gdb) 




datanicks.tar.gz
Description: Binary data


Re: [fpc-pascal]FPC Problem with reAllocMem...

2003-02-10 Thread James Mills
Another interesting thing to note as well which I think is rather
strange...

if you change in datanicks.pas lien 65,
reAllocMem(nicks, sizeOf(TNick) * nNicks);
to
getMem(nicks, sizeOf(TNick) * nNicks);

It will crash the same way as before, but at the 5th call of addNick

cheers
James

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Gratitude for FPC

2003-02-11 Thread James Mills
On Tue, Feb 11, 2003 at 12:16:50PM -0800, Mark Emerson wrote:
> Marco van de Voort wrote:
> > Yes, I think Carl did a good job there.
> 
> Wellnot only Carl...I think you ALL (on the FPC team) are doing an
> EXCELLENT job.  I'm exceedingly grateful to have this compiler, and, as
> a bonus, to also have access to communicate with its developers (that
> was impossible with Borland back in my TP days!!).
> 
> Thank you, Carl.
> Thank you, Dani?l.
> Thank you, Florian.
> Thank you, Jonas.
> Thank you, Marco.
> Thank you, Michael.
> Thank you, Peter.
> Thank you, Pierre.
> 
> And thank you to anyone else who contributed but is not named in the
> "author" list on the web site.
> 
> BTW, Michael, Peter and Pierre...where are your photos??
> 
> THANK YOU ALL for Free Pascal  :)
> 
> Mark

Yes, thank you to all FPC Developers and answering our petty little
problems :)

cheers
James

> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



[fpc-pascal]Classes and copying

2003-02-12 Thread James Mills
Hi all,

With respect to classes (and perhaps also objects), how do you copy the
contents of a class in memory (an object) to another?

ie:

var
a: TClass;
   b: TClass;

begin
  a := TClass.init;
  b := a; //This only copies the pointer and doesn't work ??
end.

cheers
James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]CompareStr

2003-02-12 Thread James Mills
On Thu, Feb 13, 2003 at 02:49:49AM +0100, Iv?n Montes wrote:
> Hi,
> 
> Maybe it's how it's supposed to be but if use :
> 
> compareStr( 'hello', 'hello-bye' ) 
> 
> I get 0, so they are equal.
> 
> If one string is bigger than the other they should be different, isn't it?
> 
> Otherways what can I use to check if two ansistrings are different?
> 
> TIA, Ivan

I think this may be a bug in the compareStr function of sysUtils.
I have tested the compareStr of sysUtils, and the compStr of the Strings
unit. The Strings unit seems to do the test ok, and the result: 'hello'
< 'hello-byte'.

cheers
James


program compare;

(*
uses
   sysUtils;
*)
uses
   Strings;

var
   (*
   str1: String;
   str2: String;
   *)
   str1: pChar;
   str2: pChar;
   r:Integer;

begin
   str1 := 'hello';
   str2 := 'hello-bye';

   writeLn('str1 = ', str1);
   writeLn('str2 = ', str2);
   writeLn;
   r := strComp(str1, str2);
   if r < 0 then
  begin
 writeLn('str1 < str2');
  end
   else if r = 0 then
  begin
 writeLn('str1 = str2');
  end
   else
  begin
 writeLn('str1 > str2');
  end;
end.


> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



[fpc-pascal]FPC Error! :(

2003-02-13 Thread James Mills
Hi,

What on earth does: schanserv.pas(715) Fatal: Internal error 55665566
mean ?

cheers
James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]Line Continuation

2003-02-13 Thread James Mills
On Thu, Feb 13, 2003 at 08:39:27PM +0200, Haluk DUMAN wrote:

Never post HTML to the list. Use PlainText.

cheers
James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]FPC Error! :(

2003-02-14 Thread James Mills
On Thu, Feb 13, 2003 at 06:04:07PM -, Lee, John wrote:
> This isn't enought info! A bit more info needed eg what version/flavour of
> fpc, date, what source are you compiling...Regards John 

Better yet, I've found out what the problem is...

unit dataChannels;

interface

uses
   sysUtils, Functions, tokenizerClass, channelClass;

var
   channels:   PChannel;
   nChannels:  Integer;

Portion of dataChannels.pas

unit channelClass;

interface

uses
   sysUtils, Functions, tokenizerClass;

type
   TNicks = class(TObject)
  constructor init(tmpNick: String);
  destructor done;
  private
 nick:   String;
 modes:  String;
 lastMsg:longInt;
  public
 procedure setNick(tmpNick: String);
 procedure addMode(tmpModes: String);
 procedure delMode(tmpModes: String);
 procedure update(cTime: longInt);

 function getNick: String;
 function getModes: String;
 function getLastMsg: longInt;
   end;
   PNicks = ^TNicks;

type
   TChannel = class(TObject)
  constructor init(channel: String);
  destructor done;
  private
 name:   String;
 topic:  String;
 nServices:  Integer;
 services:   PNicks;
 nNicks: Integer;
 nicks:  PNicks;
 modes:  String;
  public
 function getName: String;

 procedure setTopic(s: String);
 procedure addMode(tmpModes: String);
 procedure delMode(tmpModes: String);

 function getModes: String;
 function getTopic: String;

 procedure addService(nick: String);


 procedure delService(nick: String);
 function getService(index: Integer): TNicks;
 function numServices: Integer;

 procedure addNick(nick: String);
 procedure delNick(nick: String);
 function getNick(index: Integer): TNicks;
 function numNicks: Integer;
   end;
   PChannel = ^TChannel;

implementation


Portion of channelclass.pas

unit sChanServ;

interface

uses
   Services, ircCommands, Data, Functions, sysUtils, tokenizerClass,
Modules, Time, dbNicks, dataNicks, dbChannels, stringsClass, nickClass,
   Config, dataChannels, channelClass;

.
.
.

procedure TChanServ.doLIST(source: String; data: String);
var
   tokens:  TTokenizer;
   channel: String;
   what: String;
   index:   Integer;
   I:   Integer;
begin
   tokens := TTokenizer.init(data);
   channel := tokens.nextToken;
   what := tokens.nextToken;
   tokens.done;

   index := getChannel(channel);

   if upperCase(what) = 'NICKS' then
  begin
 tellUser(self, source, #2 + '***' + #2 + ' List of nicks on ' +
channel + #32 + #2 + '***' + #2);
 for I := 0 to (channels[index].numNicks - 1) do
begin
   tellUser(self, source, intToStr((I + 1)) + ' :' +
channels[index].getNick(I).getNick);
end;
 tellUser(self, source, #2 + '***' + #2 + ' End of List ' + #2 +
'***' + #2);
  end
   else
  begin
 tellUser(self, source, 'Invalid listing type.');
  end;
end;


Portion of sChanServ.pas

tellUser(self, source, intToStr((I + 1)) + ' :' + channels[index].getNick(I).getNick);

This line of code access the dataChannels module, of the variable,
channels of type PChannels (declared in channelclass.pas). Yet it is
also accessing a class inside channelclass.pas,

uses
   Services, ircCommands, Data, Functions, sysUtils, tokenizerClass,
Modules, Time, dbNicks, dataNicks, dbChannels, stringsClass, nickClass,
   Config, dataChannels, channelClass;

What causes the internal problem is when the compiler cannot find the
procedure/function of the inner class, if channelClass is left out of
the uses delcaration, that internal error will come up. Which is
undocumented.

channelClass is only needed so that the compiler knows what .getNick is
after channels[index].getNick(I)

The compiler should probably say, '(x,x) Error: Identifier not found 


??

hope this helps.

cheers
James

> 
> -Original Message-
> From: James Mills [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 13, 2003 17:21
> To: [EMAIL PROTECTED]
> Subject: [fpc-pascal]FPC Error! :(
> 
> 
> Hi,
> 
> What on earth does: schanserv.pas(715) Fatal: Internal error 55665566
> mean ?
> 
> cheers
> James
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 
> This e-mail and any attachment is for authorised use by the intended recipient(s) 
>only.  It may contain proprietary material, confidential information and/or be 
>subject to legal privilege.  It should not be copied, disclosed to, retained or used 
>by, any other party.  If you are not an intended reci

Re: [fpc-pascal]FPC Error! :(

2003-02-14 Thread James Mills
On Fri, Feb 14, 2003 at 12:54:25PM +0100, Peter Vreman wrote:
> > On Thu, Feb 13, 2003 at 06:04:07PM -, Lee, John wrote:
> >> This isn't enought info! A bit more info needed eg what version/flavour
> >> of
> >> fpc, date, what source are you compiling...Regards John
> >
> > Better yet, I've found out what the problem is...
> >
> > What causes the internal problem is when the compiler cannot find the
> > procedure/function of the inner class, if channelClass is left out of
> > the uses delcaration, that internal error will come up. Which is
> > undocumented.
> >
> > channelClass is only needed so that the compiler knows what .getNick is
> > after channels[index].getNick(I)
> >
> 
> Can you send me the sources that are failing. Then i can debug the
> problem. There is also a test in the testsuite that fails with this error,
> maybe it's the same problem.

I know the exact cause of the error. Sending the sources won't help
much, there are too many. Tell me what you need, I'll help fix this bug.

cheers
James

> 
> Peter
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]FPC Error! :(

2003-02-14 Thread James Mills
On Fri, Feb 14, 2003 at 01:46:24PM +0100, Peter Vreman wrote:
> > On Fri, Feb 14, 2003 at 12:54:25PM +0100, Peter Vreman wrote:
> >> > On Thu, Feb 13, 2003 at 06:04:07PM -, Lee, John wrote:
> >> >> This isn't enought info! A bit more info needed eg what
> >> version/flavour
> >> >> of
> >> >> fpc, date, what source are you compiling...Regards John
> >> >
> >> > Better yet, I've found out what the problem is...
> >> >
> >> > What causes the internal problem is when the compiler cannot find the
> >> > procedure/function of the inner class, if channelClass is left out of
> >> > the uses delcaration, that internal error will come up. Which is
> >> > undocumented.
> >> >
> >> > channelClass is only needed so that the compiler knows what .getNick
> >> is
> >> > after channels[index].getNick(I)
> >> >
> >>
> >> Can you send me the sources that are failing. Then i can debug the
> >> problem. There is also a test in the testsuite that fails with this
> >> error,
> >> maybe it's the same problem.
> >
> > I know the exact cause of the error. Sending the sources won't help
> > much, there are too many. Tell me what you need, I'll help fix this bug.
> 
> I need sources that i can compile and debug the compiler. i know what the
> error means but i need to run the compiler on the sources to debug why it
> fails.

Alright, can I tar up the sources that caused the error and send to your
email address ?

cheers
James

> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]reporting faults

2003-02-14 Thread James Mills
On Fri, Feb 14, 2003 at 01:12:16PM -, Lee, John wrote:
> Hello everyone...Just a reminder that it's always good to hear from you
> about faults in fpc because this helps to make it better, and you can report
> these via the web site interface, or using these [fpc-pascal] & [fpc-devel]
> mailing lists. We are approaching in the next few weeks/months a new
> release, v1.0.8, so any faults in the snapshots, v1.0.7, which are the
> v1.0.8 release candidates are especially welcome. These snapshots are
> available for a whole lot of the 'normal' fpc operating systems eg go32v2,
> win32, linux, os2 and also for many others eg m68k, solaris, amiga, beos,
> freebsd, m68k-linux, netbsd, openbsd... you can find them from the web site,
> or on ftp.freepascal.org/snapshot in the /v10 subdirectory... You'll also
> find v1.1 snapshots there.  
> 
> If you find a fault or 'feature', _please_remember to say what version,
> operating system and date it is, to include a brief summary of how it
> happened and if possible a short piece of code that demonstrates it. This
> way you'll get the fastest response (& fix if necessary) from the
> developers. Just saying 'I found a fault' isn't very helpful!  
> 
> Regards john

Hehe, thanks John. I'd just never seen a compiler internal error before
:)

James

> 
>   
> 
> This e-mail and any attachment is for authorised use by the intended recipient(s) 
>only.  It may contain proprietary material, confidential information and/or be 
>subject to legal privilege.  It should not be copied, disclosed to, retained or used 
>by, any other party.  If you are not an intended recipient then please promptly 
>delete this e-mail and any attachment and all copies and inform the sender.  Thank 
>you.
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal]use of c++ libraries

2003-02-19 Thread James Mills
On Wed, Feb 19, 2003 at 10:39:18PM +0100, Olaf Leidinger wrote:
> > > Hello everybody!
> > >
> > > Let's say I've written a nice library in c++ and I'd like to use it in
> > > Free Pascal. The list archive sais that linking c++ libs (e.g. from gnu
> > > c++) isn't possible, yet - and using dynamic c++ libs isn't possible
> > > either.
> > 
> > This is correct. It isn't supported, and it is not likely to be supported in
> > the near future. It's a complicated issue, as there are no standards for
> > name mangling in C++, which makes linking to it dependent on the C compiler
> > version used to create the lib.
>  
> So I guess there isn't something on CVS I could use?

Convert the c++ source to pascal :)

cheers
James
> 
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



[fpc-pascal]Window Maker and FPC

2003-02-23 Thread James Mills
Hi,

Has anyone attempted writing an application for Window Maker ?
More specifically, has anyone attempted to write a docked window maker
applciation ?

Just on the subject of gui applications, I take it most people use GTK
and that it is the perfered gui framework to use ?

cheers
James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]memw

2003-02-23 Thread James Mills
Hi,

This is from an old Turbo Pascal source of the Pascal S compiler source:

  getmem(spnt,((sleng+3) div 16 +1)*16);
  k := seg(spnt^);
  memw[k:0] := sleng;
  memw[k:2] := 0;
  move(sbuff[1],mem[k:4],sleng);

How would you convert that into FPC syntax for linux ?

cheers
James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Question about fp

2003-02-25 Thread James Mills
On Tue, Feb 25, 2003 at 04:11:25PM +0200, Brent Cox wrote:
> I don't know is this is the correct place to ask, if not please direct me to the 
> right place.
> 
> I am running the fp editor on mandrake 9.0. All my borders are not the normal lines 
> but are the extended charactes I.E the a with a dash above and the like. It does not 
> reconize keys F1 threw F4, yet the other F keys work??? 

Are you running it from the console or an xterm ? The xterm doesn't
emulate it well aparently (I have tried). Try running it from the
console.

cheers
James

> 
> Any ideas.
> 
> Brent
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]Slight problem

2003-03-01 Thread James Mills
Hi all,

I have a slight problem I cannot solve.
Attached is the source.
The file temp has test nicks you can paste into the test program.

datatest has the following commands:

a - add nick (paste lines from the temp file)
d - delete nick
l - list nicks
i - identify a nick

The problem is, when a single nick is added,
and then identified, it creates a duplicate.
One of the nick not identified, and the other with
it identified.

By identified, I mean that a nick is added to a TString object
inside the nick, called access.

If someone would kindly look into this, I'd be very gratefull.

cheers
James


datanicks.tar.gz
Description: Binary data


Re: [fpc-pascal]Slight problem

2003-03-01 Thread James Mills
Ignore this post. Indexing problem elsewhere in my code :(
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]BUSINESS RELATIONSHIP AND PARTNERSHIP

2003-03-15 Thread James Mills
Gawd almighty! I don't believe this idiot is still trying to post
messages to this mailing list.

*shakes head*

James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]BUSINESS RELATIONSHIP AND PARTNERSHIP

2003-03-15 Thread James Mills
On Sat, Mar 15, 2003 at 03:06:38PM +0100, Jonas Maebe wrote:
> 
> 
> On Sat, 15 Mar 2003 [EMAIL PROTECTED] wrote:
> 
> > STRICTLY PRIVATE & CONFIDENTIAL
> [snip loads more illegal crap]
> 
> This should be the last time that something like that appeared on the FPC
> mailing lists. All posts by non-subscribers now have to be approved by a
> moderator before they are distributed. This will introduce some delays for
> messages posted by people with different email addresses. They can solve
> this by subscribing all addresses they want to use to the mailing lists
> and set all but one to "no mail", otherwise they'll have to live with
> the occasional delay.

Thank you Jonas :) hehe.

James

> 
> Thank you, spammers of the of the world. NOT!
> 
> 
> Jonas
> FPC list admin
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Can I program a linux device driver with fpc?

2003-03-17 Thread James Mills
On Mon, Mar 17, 2003 at 09:22:31AM +0100, Michael Van Canneyt wrote:
> 
> 
> On Mon, 17 Mar 2003, milimeter wrote:
> 
> > Hello, everybody
> >
> >   Is there any possibility that we write a linux device driver with fpc? If we
> > can, how?
> 
> In theory it is possible. In practice, this has never been done.
> You would have to write a 'kernel-rtl' i.e. a RTL (system unit)
> which maps all basic functions (read/write/memory) to kernel
> functions. Then you can write a device driver using this RTL.

Could you show us how this is done ? As I'd like to use the same
technique to use FPC for OS Development work... I have tried but without
success... Building a minimal RTL is not easy.

cheers
James

> 
> Michael.
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Constructor failing...

2003-03-21 Thread James Mills
On Fri, Mar 21, 2003 at 02:04:39PM +0100, Michael Van Canneyt wrote:
> 
> 
> On Fri, 21 Mar 2003, Anton Tichawa wrote:
> 
> > On Friday 21 March 2003 13:09, you wrote:
> > > > On Friday 21 March 2003 12:29, you wrote:
> > > >> >> > But, when I use fail in my simple example program, it returns
> > > >> >>
> > > >> >> NIL okay but
> > > >> >>
> > > >> >> > the Heaptrace function tells me I have two unfreed memory blocks
> > > >>
> > > >> (36
> > > >>
> > > >> >> > bytes).
> > > >> >> > I can't see a memory leak anywhere else in that program, what
> > > >> >>
> > > >> >> could cause
> > > >> >>
> > > >> >> > this? (Heaptrace output is as follows: I am using FPC 1.0.6 btw)
> > > >> >>
> > > >> >> [snip heap dump]
> > > >> >>
> > > >> >> That is the exception frame that is left on the heap. I don't have
> > > >>
> > > >> the
> > > >>
> > > >> >> time to analyze what the cause is that the exception frame is not
> > > >> >> removed.
> > > >> >
> > > >> > It may be a bug in 1.0.6 which has subsequently been fixed. I
> > > >>
> > > >> downloaded
> > > >>
> > > >> > and
> > > >> > installed the 1.1 snapshots and compiled the same source code, and the
> > > >> > memory leak vanishes
> > > >>
> > > >> The reason why 1.1 has no leak is that it uses the stack to store the
> > > >> exception frames. The real problem is still there, because exception
> > > >> stack
> > > >> is still not updated
> > > >
> > > > some months ago i had a discussion with a friend, converning global
> > > > (static,
> > > > absolute) variables. his point of view was that they're not necessary
> > > > when using oop; mine was, sometimes they're absoulutely necessary.
> > > >
> > > > if we have just one level of exception processing above normal program
> > > > execution (i. e. while an exception is being processed, no other
> > > > exception will gain control), we can use absolute variables for the
> > > > exception frame.
> > > >
> > > > it's even possible to define a fixed whole number of exception layers and
> > > > allocate absolute memory for N exception levels.
> > > >
> > > > that memory space would not get lost, as it can be saved by allocating
> > > > the 'normal' stack or 'normal' heap more tightly - the old system has to
> > > > reserve
> > > > exception spae implicitely on the stack or on the heap.
> > > >
> > > > what do you think about that?
> > >
> > > It does not fix the problem, the frame is then still left on the stack.
> > >
> > > The allocation on the heap has already been changed to allocation on the
> > > stack in 1.1, because hat is much faster. Using a predefined storage of N
> > > exception levels is adding a limit and that is something we want to
> > > prevent.
> >
> > but also the power-switch, the data bus width, and the exception vectors in
> > ROM now are limits. i think limits cannot be prevented, but they can be
> > chosen knowingly, harmonic, and safe or so. every limit should include the
> > overhead to overcome it later, as things get better.
> 
> Not in this case. For instance recursive routines will get in trouble.
> There is no way to know how deep the stack can be nested, so you cannot
> foresee this. Putting a limit on that is out of the question.

Agreed. If you put a limit on that, you will disallow algorithms that
use resursive loops. There are many that do ...

cheers
James

> 
> Michael.
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]OT: An FPC program in LinuxFormat Magazine

2003-03-24 Thread James Mills
On Mon, Mar 24, 2003 at 04:17:28PM +0100, Florian Klaempfl wrote:
> A.J. Venter wrote:
> >Just in case anybody needs some ammo against people who think pascal is
> >dead.
> >This months Linux format includes AJ's Internet Cafe For LTSP (now
> >DireqCafe) which was written in FPC.
> >Just goes to show, aint no proble it can't solve.
> >
> >And before anybody acuses me of just downright spamming, yes I am the
> >A.J. that wrote it, and no I am not trying to make anybody buy it, it's
> >GPL anyway.
> >In case you do care, akinimod.sf.net, otherwize just ignore the post.
> >
> >A.J.
> 
> I think such a posting isn't off topic and it's interessting to hear 
> about such things :)

Absolutely. A lot of (up-them-selves) programmers tend to believe that
pascal is a dead language, a language for kids. I'm happy to read of
such a post. Just as a matter of interest, pascal might be an old
language, a strongly typed language, but it is certainly NOT dead and
any of my software engineer lecturers will agree with it's use as a
language for developing software.

my 2 cents...

James

> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]OT: An FPC program in LinuxFormat Magazine

2003-03-25 Thread James Mills
On Tue, Mar 25, 2003 at 08:26:16AM +0100, Anton Tichawa wrote:
> On Monday 24 March 2003 23:16, you wrote:
> > On Mon, Mar 24, 2003 at 04:17:28PM +0100, Florian Klaempfl wrote:
> > > A.J. Venter wrote:
> > > >Just in case anybody needs some ammo against people who think pascal is
> > > >dead.
> > > >This months Linux format includes AJ's Internet Cafe For LTSP (now
> > > >DireqCafe) which was written in FPC.
> > > >Just goes to show, aint no proble it can't solve.
> > > >
> > > >And before anybody acuses me of just downright spamming, yes I am the
> > > >A.J. that wrote it, and no I am not trying to make anybody buy it, it's
> > > >GPL anyway.
> > > >In case you do care, akinimod.sf.net, otherwize just ignore the post.
> > > >
> > > >A.J.
> > >
> > > I think such a posting isn't off topic and it's interessting to hear
> > > about such things :)
> >
> > Absolutely. A lot of (up-them-selves) programmers tend to believe that
> > pascal is a dead language, a language for kids. I'm happy to read of
> > such a post. Just as a matter of interest, pascal might be an old
> > language, a strongly typed language, but it is certainly NOT dead and
> > any of my software engineer lecturers will agree with it's use as a
> > language for developing software.
> >
> > my 2 cents...
> 
> btw - please can you explain that idiom - "my 2 cents"? thanx.

Would it sound better as: my contribution ?

cheers
James

> 
> --
> 
> "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte 
> Berechnungen einzuweben."
> 
> Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
> 
> --
> 
> Anton Tichawa
> Volkertstrasse 19 / 20
> A-1020 Wien
> mobil: +43 664 52 07 907
> email: [EMAIL PROTECTED]
> 
> --
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Lazarus +FPC

2003-03-28 Thread James Mills
On Fri, Mar 28, 2003 at 02:52:31PM +0200, A.J. Venter wrote:
> Hi,
> How much compatibility is broken between fpc-1.0.6 and fpc-laz 1.0.7 ?

Why can't Lazarus be run with just the normal FPC compiler anyway ? Why
does it have to have a specially built compiler ?

James
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Lazarus +FPC

2003-03-28 Thread James Mills
On Fri, Mar 28, 2003 at 02:41:17PM +0100, Marco van de Voort wrote:
> > On Fri, Mar 28, 2003 at 02:52:31PM +0200, A.J. Venter wrote:
> > > Hi,
> > > How much compatibility is broken between fpc-1.0.6 and fpc-laz 1.0.7 ?
> > 
> > Why can't Lazarus be run with just the normal FPC compiler anyway ? Why
> > does it have to have a specially built compiler ?
> 
> In general, there is no reason, just that always small problems pop up when a large
> project as Lazarus is made.
> 
> Delphi incompabilities and  recompiling problems (circular reference) that
> are dectected and fixed after a release have been the usual reasons for
> requiring snapshots. 
> 
> Though the amount of problems seems to decrease with each new fixes version, and 
> I hope that trend continues

In future will we see Lazurs start to work with the normal FPC compilers
without the additional need to download and install the a specially
built compiler for it ?

cheers
James

> 
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]OpenGL/GLUT run time error when I whant compile this code

2003-04-04 Thread James Mills
On Sat, Apr 05, 2003 at 10:02:07AM +0800, Karim Forsthofer wrote:
> Hello 
> I played around with the OpenGL unit, and I wrote some minimal OpenGL code to get a 
> window: 
> Here is the code:
> 
> program glbasic;
> 
> uses
>   gl, glut;
> 
> const
>   width = 640;
>   height= 480;
> 
> procedure drawthings;
> 
> begin
>   glClearColor(0.0, 0.0, 0.0, 0.0);
>  (*will add some more code*);
> end;
> 
> begin 
>   glutInit(@argc, argv);
>   glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGB);
>   glutInitWindowSize( width, height);
>   glutInitWindowPosition(0, 0);
>   glutCreateWindow('glbasic');
>   glutDisplayFunc(@drawthings);
>   glutMainLoop();
> end.
> 
> Now, when I whant to run to code, I get some Run time errors on the console: 
> 
> Runtime error 216 at 0x4052F5CA
>0x4051F5CA
> Runtime error 216 at 0x0804C1CA
>0x0849C1CA
>0x0805127E
>
>etc. 
>etc. 
>etc. (about 20 lines)
> 
> 1). I know not a lot of runtime errors, but after succesfully compiling, that isn`t 
> a fpc bug, is it ? 
> What is the source of this run time error ? (mesa, fpc or my code ?)
> 2). I think about there isn`t enough code in the drawthings procedure to run 
> succesfull. 
> 
> What you think ? 

That piece of code runs fine on my machine, except that my display
doesn't support OpenGL GLX Extension :( hehe, need to compile my nvidia
kernel drivers...

cheer
sJames

> 
> Greetings 
> Karim F. 
> 
> -- 
> __
> http://www.linuxmail.org/
> Now with e-mail forwarding for only US$5.95/yr
> 
> Powered by Outblaze
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]CGI Programming

2003-06-07 Thread James Mills
Hi all,

Now that uni is almost over (only exams left), I wish to write a web
application for my 5 member group of software engineers (students).

Is it wise to write such as application (cgi app in pascal) ?
It needs to be secure and allow only members of the group to login and
view the pages within, submit data etc...

I've looked around for cgi related stuff for fpc, ezcgi, Uncgi (from:
ftp://ftp.freepascal.org/pub/fpc/source/packages.zip) which doesn't
appear to exist.

I have seen Section 11 of the Users Manual of FPC as well which explains
how the two methods of feeding the data to the cgi app.

Anyone have any ideas of the best approach to this ? I could write my
own class, but ezcgi probably already accomplishes most things anyway.

cheers
James

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]Strange error with a simple class

2003-06-08 Thread James Mills
Hi,

I get the following with a very simple class:

Runtime error 216 at 0x0805A735
  0x0805A735
  0x080481FF  TCONFIG__PRINT,  line 29 of configclass.pas
  0x0805BE35  main,  line 29 of forum.pas
  0x080480B0

Any ideas ?

cheers
James

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG
unit configClass;

interface

type
	TConfig = class(TObject)
		constructor Create;
		private
			fileName:	String;
		public
			temp:	String;
			procedure print;
	end;

implementation

constructor TConfig.Create;
begin
	temp := 'hello';
	inherited Create;
end;

procedure TConfig.print;
begin
	writeLn('#Forum Configuration:');
	writeLn('#');

	writeLn('/General/');
	writeLn('templateDir=', temp);
	writeLn;
end;

end.


[fpc-pascal]Strange error from a simple class

2003-06-08 Thread James Mills
Hi,

I get this error from a very simple class:

Runtime error 216 at 0x0805A735
  0x0805A735
  0x080481FF  TCONFIG__PRINT,  line 29 of configclass.pas
  0x0805BE35  main,  line 29 of forum.pas
  0x080480B0

Any ideas ?

cheers
James
unit configClass;

interface

type
	TConfig = class(TObject)
		constructor Create;
		private
			fileName:	String;
		public
			temp:	String;
			procedure print;
	end;

implementation

constructor TConfig.Create;
begin
	temp := 'hello';
	inherited Create;
end;

procedure TConfig.print;
begin
	writeLn('#Forum Configuration:');
	writeLn('#');

	writeLn('/General/');
	writeLn('templateDir=', temp);
	writeLn;
end;

end.


Re: [fpc-pascal]Strange error from a simple class

2003-06-08 Thread James Mills
On Sun, Jun 08, 2003 at 04:43:21PM +0200, Michael Van Canneyt wrote:
> 
> 
> On Sun, 8 Jun 2003, James Mills wrote:
> 
> > Hi,
> >
> > I get this error from a very simple class:
> >
> > Runtime error 216 at 0x0805A735
> >   0x0805A735
> >   0x080481FF  TCONFIG__PRINT,  line 29 of configclass.pas
> >   0x0805BE35  main,  line 29 of forum.pas
> >   0x080480B0
> >
> > Any ideas ?
> 
> You should also show the forum.pas file.
> The constructor Create should be in the 'public'  section of the class,
Ahh I think that's where my error lies. (stupid me)

cheers
James

> not in the first (private) section.
> 
> Michael.
> 
> 
> _______
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Strange error from a simple class

2003-06-08 Thread James Mills
On Mon, Jun 09, 2003 at 12:57:24AM +1000, James Mills wrote:
> On Sun, Jun 08, 2003 at 04:43:21PM +0200, Michael Van Canneyt wrote:
> > 
> > 
> > On Sun, 8 Jun 2003, James Mills wrote:
> > 
> > > Hi,
> > >
> > > I get this error from a very simple class:
> > >
> > > Runtime error 216 at 0x0805A735
> > >   0x0805A735
> > >   0x080481FF  TCONFIG__PRINT,  line 29 of configclass.pas
> > >   0x0805BE35  main,  line 29 of forum.pas
> > >   0x080480B0
> > >
> > > Any ideas ?
> > 
> > You should also show the forum.pas file.
> > The constructor Create should be in the 'public'  section of the class,
> Ahh I think that's where my error lies. (stupid me)
> 
> cheers
> James

Actually it makes no difference, so I'll attach all relevant files.

cheers
James

> 
> > not in the first (private) section.
> > 
> > Michael.
> > 
> > 
> > ___
> > fpc-pascal maillist  -  [EMAIL PROTECTED]
> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 
> -- 
> -
> - James Mills
> Zero Defect Software Engineers Group - ZDSEG
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG
unit Config;

interface

uses
	configClass;

procedure init;
procedure done;
procedure load;
procedure print;

var
	conf:			TConfig;
	confFile:	String;

implementation

procedure init;
begin
	confFile := 'forum.conf';
end;

procedure done;
begin
	conf.Destroy;
end;

procedure load;
begin
	conf := TConfig.Create;
end;

procedure print;
begin
	conf.print;
end;

end.
unit configClass;

interface

type
	TConfig = class(TObject)
		private
			fileName:	String;
		public
			temp:	String;
			constructor Create;
			procedure print;
	end;

implementation

constructor TConfig.Create;
begin
	temp := 'hello';
	inherited Create;
end;

procedure TConfig.print;
begin
	writeLn('#Forum Configuration:');
	writeLn('#');

	writeLn('/General/');
	writeLn('templateDir=', temp);
	writeLn;
end;

end.
program forum;

uses
	Linux, Config;

const max_data = 1000;

type datarec = record
  name,value : string;
  end;

var data : array[1..max_data] of datarec;
i,nrdata : longint;
c  : char;
literal,aname : boolean;
	


var
	s:	String;
	f:	Text;

begin
	config.init;
writeln ('Content-type: text/html');
writeln;
if getenv('REQUEST_METHOD')<>'POST' then
   begin
		conf.print;
		assign(f, '/home/prologic/www/data/forum/templates/index.html');
		reset(f);
		while not EOF(f) do
			begin
readLn(f, s);
writeLn(s);
			end;
		close(f);
   halt(1);
   end;
if getenv('CONTENT_TYPE')<>'application/x-www-form-urlencoded' then
   begin
   writeln ('This script can only be used to decode form results');
   halt(1);
   end;
nrdata:=1;
aname:=true;
while not eof(input) do
  begin
  literal:=false;
  read(c);
  if c='\' then
 begin
 literal:=true;
 read(c);
 end;
  if literal or ((c<>'=') and (c<>'&')) then
 with data[nrdata] do
if aname then name:=name+c else value:=value+c
  else
 begin
 if c='&' then
 begin
 inc (nrdata);
 aname:=true;
 end
  else
 aname:=false;
  end
  end;
writeln ('Form Results :');
writeln ('You submitted the following name/value pairs :');
writeln ('');
for i:=1 to nrdata do writeln (' ',data[i].name,' = ',data[i].value);
writeln ('');

end.



Re: [fpc-pascal]Strange error from a simple class

2003-06-08 Thread James Mills
On Sun, Jun 08, 2003 at 05:39:51PM +0200, Michael Van Canneyt wrote:
> 
> 
> On Mon, 9 Jun 2003, James Mills wrote:
> 
> > On Mon, Jun 09, 2003 at 12:57:24AM +1000, James Mills wrote:
> > > On Sun, Jun 08, 2003 at 04:43:21PM +0200, Michael Van Canneyt wrote:
> > > >
> > > >
> > > > On Sun, 8 Jun 2003, James Mills wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I get this error from a very simple class:
> > > > >
> > > > > Runtime error 216 at 0x0805A735
> > > > >   0x0805A735
> > > > >   0x080481FF  TCONFIG__PRINT,  line 29 of configclass.pas
> > > > >   0x0805BE35  main,  line 29 of forum.pas
> > > > >   0x080480B0
> > > > >
> > > > > Any ideas ?
> > > >
> > > > You should also show the forum.pas file.
> > > > The constructor Create should be in the 'public'  section of the class,
> > > Ahh I think that's where my error lies. (stupid me)
> > >
> > > cheers
> > > James
> >
> > Actually it makes no difference, so I'll attach all relevant files.
> 
> You forget to do a load statement before the print. Actually, I think
> you swapped init and load. In init you should create the class instance,
> and in load you should load whatever values are needed.

God damn it! You're right. I guess you get that runtime error when
trying to access a non-existant class in memory ?

Thank you Michael, I must have been braindead.

cheers
James

> 
> You skipped the creation step in your code.
> 
> Michael.
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]ezCGI Source

2003-06-08 Thread James Mills
Hi,

Where can I find the source for ezcgi ? Or must I download the entire
fcl source (where is this also?)

cheers
James

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]CGI Programming

2003-06-09 Thread James Mills
On Mon, Jun 09, 2003 at 06:10:25AM -0600, [EMAIL PROTECTED] wrote:
> 
>  
> > 
> > ezcgi is outdated. The new release 1.0.8 contains the 'cgiapp' unit
> > which has all that ezcgi had, but is embedded more in the FCL.

ezcgi is outdated ? It suits me just fine :)

How is cgiapp better than ezcgi (just because it's more embedded into
the FCL?)

cheers
James

> > 
> > I suggest you download the latest FCL sources, or get the new release.
> > 
> Is there a binding for FastCGI ? It is a good alternative to plain CGI.
> 
> cheers,
> -Krish
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]CGI Programming

2003-06-09 Thread James Mills
On Mon, Jun 09, 2003 at 09:50:33PM +0200, Michael Van Canneyt wrote:
> 
> 
> On Mon, 9 Jun 2003, James Mills wrote:
> 
> > On Mon, Jun 09, 2003 at 06:10:25AM -0600, [EMAIL PROTECTED] wrote:
> > >
> > >
> > > >
> > > > ezcgi is outdated. The new release 1.0.8 contains the 'cgiapp' unit
> > > > which has all that ezcgi had, but is embedded more in the FCL.
> >
> > ezcgi is outdated ? It suits me just fine :)
> >
> > How is cgiapp better than ezcgi (just because it's more embedded into
> > the FCL?)
> 
> ezcgi uses some dirty tricks to get at the needed variables under windows.
> cgiapp is entirely cross-platform. But it was based heavily on ezcgi.
> 
> I don't want to say that ezcgi was bad, not at all. Just cgiapp fits more
> in a general approach to applications we want to introduce in the FCL,
> and which was not present when ezcgi was first developed.

Well it suits me just fine since I don't really care about developing a
cgi app for windows :P I mean come on, who in their right mind would run
an MS http server with all the exploits known to it ? (Even my bloody
apache server gets attacked with MS explits, the fools).

cheers
James

> 
> Michael.
> 
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]Error compiling testdb.pp example (mysql)

2003-06-14 Thread James Mills
$ fpc testdb
Free Pascal Compiler version 1.0.6 [2002/08/10] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling testdb.pas
Assembling qtest
Linking testdb
testdb.o(.text+0xaa): In function `program_init':
: undefined reference to `mysql_connect'
testdb.pas(84,3) Error: Error while linking
Closing script ppas.sh

What have I done wrong here ? ...
Yes I have installed the appropiate libmysqlclient-dev (from debian).

cheers
James

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Error compiling testdb.pp example (mysql)

2003-06-14 Thread James Mills
On Sat, Jun 14, 2003 at 04:08:38PM +0200, [EMAIL PROTECTED] wrote:
> 
> 
> On Sat, 14 Jun 2003, James Mills wrote:
> 
> > $ fpc testdb
> > Free Pascal Compiler version 1.0.6 [2002/08/10] for i386
> > Copyright (c) 1993-2002 by Florian Klaempfl
> > Target OS: Linux for i386
> > Compiling testdb.pas
> > Assembling qtest
> > Linking testdb
> > testdb.o(.text+0xaa): In function `program_init':
> > : undefined reference to `mysql_connect'
> > testdb.pas(84,3) Error: Error while linking
> > Closing script ppas.sh
> >
> > What have I done wrong here ? ...
> > Yes I have installed the appropiate libmysqlclient-dev (from debian).
> 
> It is not the correct version of mysql. Please check what the mysql_version
> unit reports as a version, and what the version is of the installed mysql.

How on earth do I do that :P ?

cheers
James

> 
> Michael.
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Error compiling testdb.pp example (mysql)

2003-06-14 Thread James Mills
On Sat, Jun 14, 2003 at 05:01:38PM +0200, [EMAIL PROTECTED] wrote:
> 
> 
> On Sun, 15 Jun 2003, James Mills wrote:
> 
> > On Sat, Jun 14, 2003 at 04:08:38PM +0200, [EMAIL PROTECTED] wrote:
> > >
> > >
> > > On Sat, 14 Jun 2003, James Mills wrote:
> > >
> > > > $ fpc testdb
> > > > Free Pascal Compiler version 1.0.6 [2002/08/10] for i386
> > > > Copyright (c) 1993-2002 by Florian Klaempfl
> > > > Target OS: Linux for i386
> > > > Compiling testdb.pas
> > > > Assembling qtest
> > > > Linking testdb
> > > > testdb.o(.text+0xaa): In function `program_init':
> > > > : undefined reference to `mysql_connect'
> > > > testdb.pas(84,3) Error: Error while linking
> > > > Closing script ppas.sh
> > > >
> > > > What have I done wrong here ? ...
> > > > Yes I have installed the appropiate libmysqlclient-dev (from debian).
> > >
> > > It is not the correct version of mysql. Please check what the mysql_version
> > > unit reports as a version, and what the version is of the installed mysql.
> >
> > How on earth do I do that :P ?
> 
> Simple:
> 
> program ver;
> 
> uses mysql_version;
> 
> begin
>   Writeln(MYSQL_SERVER_VERSION);
> end.

Okay I didn't know such a unit existed :)

Here's the info you wanted...

cheers
James

$ fpc test
Free Pascal Compiler version 1.0.6 [2002/08/10] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling test.pas
Assembling ver
Linking test
8 Lines compiled, 1.0 sec

[EMAIL PROTECTED]
Sun Jun 15 01:05:14
~
$ ./test
3.21.28-gamma

[EMAIL PROTECTED]
Sun Jun 15 01:05:15
~
$ mutt
Mailbox is unchanged.

[EMAIL PROTECTED]
Sun Jun 15 01:05:27
~
$ cat /usr/include/mysql/mysql_version.h
/* Copyright Abandoned 1996, 1999, 2001 MySQL AB
   This file is public domain and comes with NO WARRANTY of any kind */

/* Version numbers for protocol & mysqld */

#ifndef _mysql_version_h
#define _mysql_version_h
#ifdef _CUSTOMCONFIG_
#include 
#else
#define PROTOCOL_VERSION10
#define MYSQL_SERVER_VERSION"4.0.13"
#ifndef MYSQL_SERVER_SUFFIX
#define MYSQL_SERVER_SUFFIX ""
#endif
#define FRM_VER 6
#define MYSQL_VERSION_ID40013
#define MYSQL_PORT  3306
#define MYSQL_UNIX_ADDR "/var/run/mysqld/mysqld.sock"
#define MYSQL_CONFIG_NAME   "my"

/* mysqld compile time options */
#ifndef MYSQL_CHARSET
#define MYSQL_CHARSET   "latin1"
#endif /* MYSQL_CHARSET */
#endif /* _CUSTOMCONFIG_ */
#endif /* _mysql_version_h */

> 
> and
>   cat /usr/include/mysql/mysql_version.h
> 
> Should tell you what is installed.
> 
> Michael.
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Error compiling testdb.pp example (mysql)

2003-06-14 Thread James Mills
On Sat, Jun 14, 2003 at 06:30:09PM +0200, [EMAIL PROTECTED] wrote:
> 
> 
> On Sun, 15 Jun 2003, James Mills wrote:
> 
> > On Sat, Jun 14, 2003 at 05:01:38PM +0200, [EMAIL PROTECTED] wrote:
> > >
> > >
> > > On Sun, 15 Jun 2003, James Mills wrote:
> > >
> > > > On Sat, Jun 14, 2003 at 04:08:38PM +0200, [EMAIL PROTECTED] wrote:
> > > > >
> > > > >
> > > > > On Sat, 14 Jun 2003, James Mills wrote:
> > > > >
> > > > > > $ fpc testdb
> > > > > > Free Pascal Compiler version 1.0.6 [2002/08/10] for i386
> > > > > > Copyright (c) 1993-2002 by Florian Klaempfl
> > > > > > Target OS: Linux for i386
> > > > > > Compiling testdb.pas
> > > > > > Assembling qtest
> > > > > > Linking testdb
> > > > > > testdb.o(.text+0xaa): In function `program_init':
> > > > > > : undefined reference to `mysql_connect'
> > > > > > testdb.pas(84,3) Error: Error while linking
> > > > > > Closing script ppas.sh
> > > > > >
> > > > > > What have I done wrong here ? ...
> > > > > > Yes I have installed the appropiate libmysqlclient-dev (from debian).
> > > > >
> > > > > It is not the correct version of mysql. Please check what the mysql_version
> > > > > unit reports as a version, and what the version is of the installed mysql.
> > > >
> > > > How on earth do I do that :P ?
> > >
> > > Simple:
> > >
> > > program ver;
> > >
> > > uses mysql_version;
> > >
> > > begin
> > >   Writeln(MYSQL_SERVER_VERSION);
> > > end.
> >
> > Okay I didn't know such a unit existed :)
> >
> > Here's the info you wanted...
> 
> Correction: the info which you need :-)
> 
> Seems that you have mysql version 4 installed.
> The units we distribute standard work with MySQL 3.23.
> 
> There are units for mysql version 4 as well, but you must compile and
> install them separately. Get the sources of the packages , and look in
> packages/base/mysql/mysql4
> 
> I warn against using mysql with FPC. Their API changes quite often in
> incompatible ways, which can be masked with C macros but which cannot
> be masked with Pascal functions.
> 
> Try and use firebird instead is my usual advice.

What about sqlite ? Has anyone gotten that to work in any application
they've developed.

cheers
James

> 
> Michael.
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Error compiling testdb.pp example (mysql)

2003-06-15 Thread James Mills
On Sun, Jun 15, 2003 at 12:34:07PM +0200, [EMAIL PROTECTED] wrote:
> 
> 
> On Sun, 15 Jun 2003, James Mills wrote:
> 
> > On Sat, Jun 14, 2003 at 06:30:09PM +0200, [EMAIL PROTECTED] wrote:
> > >
> > >
> > > On Sun, 15 Jun 2003, James Mills wrote:
> > >
> > > > On Sat, Jun 14, 2003 at 05:01:38PM +0200, [EMAIL PROTECTED] wrote:
> > > > >
> > > > >
> > > > > On Sun, 15 Jun 2003, James Mills wrote:
> > > > >
> > > > > > On Sat, Jun 14, 2003 at 04:08:38PM +0200, [EMAIL PROTECTED] wrote:
> > > > > > >
> > > > > > >
> > > > > > > On Sat, 14 Jun 2003, James Mills wrote:
> > > > > > >
> > > > > > > > $ fpc testdb
> > > > > > > > Free Pascal Compiler version 1.0.6 [2002/08/10] for i386
> > > > > > > > Copyright (c) 1993-2002 by Florian Klaempfl
> > > > > > > > Target OS: Linux for i386
> > > > > > > > Compiling testdb.pas
> > > > > > > > Assembling qtest
> > > > > > > > Linking testdb
> > > > > > > > testdb.o(.text+0xaa): In function `program_init':
> > > > > > > > : undefined reference to `mysql_connect'
> > > > > > > > testdb.pas(84,3) Error: Error while linking
> > > > > > > > Closing script ppas.sh
> > > > > > > >
> > > > > > > > What have I done wrong here ? ...
> > > > > > > > Yes I have installed the appropiate libmysqlclient-dev (from debian).
> > > > > > >
> > > > > > > It is not the correct version of mysql. Please check what the 
> > > > > > > mysql_version
> > > > > > > unit reports as a version, and what the version is of the installed 
> > > > > > > mysql.
> > > > > >
> > > > > > How on earth do I do that :P ?
> > > > >
> > > > > Simple:
> > > > >
> > > > > program ver;
> > > > >
> > > > > uses mysql_version;
> > > > >
> > > > > begin
> > > > >   Writeln(MYSQL_SERVER_VERSION);
> > > > > end.
> > > >
> > > > Okay I didn't know such a unit existed :)
> > > >
> > > > Here's the info you wanted...
> > >
> > > Correction: the info which you need :-)
> > >
> > > Seems that you have mysql version 4 installed.
> > > The units we distribute standard work with MySQL 3.23.
> > >
> > > There are units for mysql version 4 as well, but you must compile and
> > > install them separately. Get the sources of the packages , and look in
> > > packages/base/mysql/mysql4
> > >
> > > I warn against using mysql with FPC. Their API changes quite often in
> > > incompatible ways, which can be masked with C macros but which cannot
> > > be masked with Pascal functions.
> > >
> > > Try and use firebird instead is my usual advice.
> >
> > What about sqlite ? Has anyone gotten that to work in any application
> > they've developed.
> 
> I don't know of any report. But if you want to give it a try,
> I just converted the C headers for it, I can send them to you.

Please :) I would love them as I have no idea how to convert C headers
myself. Need to learn one day...
All I have here is a pascal unit for beos but it either doesn't work, or
there's a in sqlite (which I completely doubt). If you want to have a
look at that, search for: "sqlite beos pascal" on google.

But yeah, please send them :)

cheers
James

> 
> Michael.
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal](Auto) XML Record Loader - Exist?

2003-06-16 Thread James Mills
On Tue, Jun 17, 2003 at 12:13:53AM +0200, RRC2Soft wrote:
> Hello all!
> 
> I want to know if there's a tool that creates the OpenXML code needed
> for loading and saving an entire record from/to XML automatically.

What would the purpose of this be ?

cheers
James

> 
> 
> 
> Example:
> Type TCoord = Record
> X,Y:Integer;
>   end;
>  TActor = Record
> Coord:TCoord;
> Name:String;
>   end;
> 
> <=Code=>
> 
> 
>
>1 
>2 >/Y>
>
> RUI BRENNAN 
> 
> 
> Thanks,
>Rodrigo "Rui" R. (1/2 RRC?Soft)
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]SDL with FPC - possible?

2003-06-20 Thread James Mills
On Thu, Jun 19, 2003 at 07:05:58PM +0200, Holger Peters wrote:
> Hi,
> 
> I have used SDL4FreePascal for some time. Simplysearch it with google. 
> It worked fine with FPC 1.0.6 under Windows, I have not used it under 
> Linux, but I guess it is about the same.

It works very well under Linux also :)

cheers
James

> 
> Please notice that libsdl is not ported completely.
> 
> 
> Holger
> 
> Marco van de Voort schrieb:
> 
> >>Are there any libsdl units for FPC available? Sorry if
> >>it's too trivial, or discussed in the near future, but
> >>i can't find it between the packages in the CVS, and
> >>i have no time to dig myself into the problem right 
> >>now...  
> >>   
> >>
> >
> >I do know that there are Jedi SDL bindings, and did you check
> >contributed units?
> >
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]SQLite and FPC

2003-06-25 Thread James Mills
Hi all,

I'm wondering if anyone would do me the favour of either writing a unit
for sqlite (2.8.3) or fixing Eric Jourde's BeOS unit which doesn't work
for the current SQLite version (2.8.3).

I do not have the skills necessary to interface C libraries and pascal.
Michael.VanCann converted the headers for SQLite (2.8.3 I believe) to
fpc, I'll include these as well as Eric Jourde's unit.

I'd very much appriciate anyone's help with this, as I plan to use
SQLite in my project as an embedded database system.

cheers
James

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG


beos-sqlite-unit.tar.gz
Description: Binary data
{$mode objfpc}
unit sqlite;
interface

{
  Automatically converted by H2Pas 0.99.15 from sqlite.h
  The following command line parameters were used:
-S
-D
-p
-l
sqlite
sqlite.h
}

  const
External_library='sqlite'; {Setup as you need}

  { Pointers to basic pascal types, inserted by h2pas conversion program.}
  Type
PLongint  = ^Longint;
PSmallInt = ^SmallInt;
PByte = ^Byte;
PWord = ^Word;
PDWord= ^DWord;
PDouble   = ^Double;
PPPchar   = ^ppchar;

{$PACKRECORDS C}

const
  _SQLITE_VERSION = '2.8.3';
  SQLITE_ISO8859 = 1;

var
  sqlite_version  : pchar;cvar;external;
  sqlite_encoding : pchar;cvar;external;

const
  SQLITE_OK = 0;
  SQLITE_ERROR  = 1;
  SQLITE_INTERNAL   = 2;
  SQLITE_PERM   = 3;
  SQLITE_ABORT  = 4;
  SQLITE_BUSY   = 5;
  SQLITE_LOCKED = 6;
  SQLITE_NOMEM  = 7;
  SQLITE_READONLY   = 8;
  SQLITE_INTERRUPT  = 9;
  SQLITE_IOERR  = 10;
  SQLITE_CORRUPT= 11;
  SQLITE_NOTFOUND   = 12;
  SQLITE_FULL   = 13;
  SQLITE_CANTOPEN   = 14;
  SQLITE_PROTOCOL   = 15;
  SQLITE_EMPTY  = 16;
  SQLITE_SCHEMA = 17;
  SQLITE_TOOBIG = 18;
  SQLITE_CONSTRAINT = 19;
  SQLITE_MISMATCH   = 20;
  SQLITE_MISUSE = 21;
  SQLITE_NOLFS  = 22;
  SQLITE_AUTH   = 23;
  SQLITE_FORMAT = 24;
  SQLITE_ROW= 100;
  SQLITE_DONE   = 101;


  SQLITE_COPY= 0;
  SQLITE_CREATE_INDEX= 1;
  SQLITE_CREATE_TABLE= 2;
  SQLITE_CREATE_TEMP_INDEX   = 3;
  SQLITE_CREATE_TEMP_TABLE   = 4;
  SQLITE_CREATE_TEMP_TRIGGER = 5;
  SQLITE_CREATE_TEMP_VIEW= 6;
  SQLITE_CREATE_TRIGGER  = 7;
  SQLITE_CREATE_VIEW = 8;
  SQLITE_DELETE  = 9;
  SQLITE_DROP_INDEX  = 10;
  SQLITE_DROP_TABLE  = 11;
  SQLITE_DROP_TEMP_INDEX = 12;
  SQLITE_DROP_TEMP_TABLE = 13;
  SQLITE_DROP_TEMP_TRIGGER   = 14;
  SQLITE_DROP_TEMP_VIEW  = 15;
  SQLITE_DROP_TRIGGER= 16;
  SQLITE_DROP_VIEW   = 17;
  SQLITE_INSERT  = 18;
  SQLITE_PRAGMA  = 19;
  SQLITE_READ= 20;
  SQLITE_SELECT  = 21;
  SQLITE_TRANSACTION = 22;
  SQLITE_UPDATE  =  23;
  SQLITE_DENY= 1;
  SQLITE_IGNORE  = 2;

  SQLITE_NUMERIC = -1;
  SQLITE_TEXT= -2;
  SQLITE_ARGS= -3;

  
Type
  Psqlite = Pointer;
  Psqlite_vm = Pointer;
  PPsqlite_vm = ^Psqlite_vm;
  Psqlite_func = Pointer;
  
  // Procedural types used in functions.
  
  sqlite_callback = function (_para1:pointer; _para2:longint; _para3:PPchar; _para4:PPchar):longint;{$ifdef win32}stdcall{$else}cdecl{$endif};
  sqlite_trace_func = procedure (_para1:pointer; _para2:Pchar);{$ifdef win32}stdcall{$else}cdecl{$endif};
  sqlite_create_func = procedure (_para1:Psqlite_func; _para2:longint; _para3:PPchar);{$ifdef win32}stdcall{$else}cdecl{$endif};
  sqlite_handler = function (_para1:pointer; _para2:Pchar; _para3:longint):longint;{$ifdef win32}stdcall{$else}cdecl{$endif};
  sqlite_step_func = procedure (_para1:Psqlite_func; _para2:longint; _para3:PPchar)  ;{$ifdef win32}stdcall{$else}cdecl{$endif};
  sqlite_finalize_func = procedure (_para1:Psqlite_func);{$ifdef win32}stdcall{$else}cdecl{$endif};
  sqlite_authorize_func = function (_para1:pointer; _para2:longint; _para3, _para4,_para5,_para6:Pchar):longint;{$ifdef win32}stdcall{$else}cdecl{$endif};
  
  function sqlite_create_function(_para1:Psqlite; zName:Pchar; nArg:longint; xFunc:sqlite_create_func; pUserData:pointer):longint;{$ifdef win32}stdcall{$else}cdecl{$endif};external External_library name 'sqlite_create_function';
  function sqlite_open(filename:Pchar; mode:longint; errmsg:PPchar):Psqlite;{$ifdef win32}stdcall{$else}cdecl{$endif};external External_library name 'sqlite_open';
  procedure sqlite_close(_para1:Psqlite);{$ifdef win32}stdcall{$else}cdecl{$endif};external External_library name 'sqlite_close';
  function sqlite_exec(_para1:Psqlite; sql:Pchar; _para3:sqlite_callback; _para4:pointer; errmsg:PPchar):longint;{$ifdef win32}stdcall{$else}cdecl{$endif};external External_library name 'sqlite_exec';
  function sqlite_last_insert_rowid(_para1:Psqlite):longint;{$ifdef win32}stdcall{$else}cdecl{$endif};external External_library n

Re: [fpc-pascal]SQLite and FPC

2003-06-25 Thread James Mills
On Wed, Jun 25, 2003 at 11:08:35AM +0200, Michael Van Canneyt wrote:
> 
> 
> On Wed, 25 Jun 2003, James Mills wrote:
> 
> > Hi all,
> >
> > I'm wondering if anyone would do me the favour of either writing a unit
> > for sqlite (2.8.3) or fixing Eric Jourde's BeOS unit which doesn't work
> > for the current SQLite version (2.8.3).
> >
> > I do not have the skills necessary to interface C libraries and pascal.
> > Michael.VanCann converted the headers for SQLite (2.8.3 I believe) to
> > fpc, I'll include these as well as Eric Jourde's unit.
> 
> What is the problem with the converted header files ? Is it not enough ?

Ahh Michael. No nothing is wrong with them, I just have never used C ->
Pascal interfaces before, and I thought it wouldn't be that hard to fix
Eric Jourde's unit (which did work for SQLite 2.7.3 he said...). But
it's obviously been quite hard for me, even Eric himself seems to be
busy with other things and hasn't much interest in fixing his unit.

*sighs* Sorry Michael,

James

> 
> Michael.
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]TCollection question

2003-07-06 Thread James Mills
Is there an example of using TCollection or something (without having to
write the code myself) that manages a collection of FPC style classes
(objects) ?

I'd like to see one, code I have written to handle a dynamic array of
objects has gone out of control... (Using FPC classes here)

cheers
James

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]TCollection question

2003-07-06 Thread James Mills
On Sun, Jul 06, 2003 at 04:25:15PM +0200, Marco van de Voort wrote:
> > Is there an example of using TCollection or something (without having to
> > write the code myself) that manages a collection of FPC style classes
> > (objects) ?
> > 
> > I'd like to see one, code I have written to handle a dynamic array of
> > objects has gone out of control... (Using FPC classes here)
> 
> IIRC, TCollection only stores TCollectionItem derived classes.
> 
> TList is closer to what you want probably.

Is there an example other than list.pp in the fcl source ?

Also just for the record of knowing... I have attached datanicks.pas
which hold a dynamic array of TNick ... Is this what TList already does
(if so I'm wasting my time writing my own code...) ?

cheers
James

> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG
unit dataNicks;

interface

uses
	sysUtils, Functions, tokenizerClass, nickClass;

var
	nicks:	PNick;
	nNicks:	Integer;

procedure init;
procedure done;

procedure addNick(data: String);
procedure addNick(data: String; index: Integer);
function backupNick(nick: String): TNick;
procedure copyNickData(srcNick: TNick; destNick: TNick);
function getNick(nick: String): Integer;
procedure delNick(nick: String);

function isIdentified(nick: String): Boolean;
function isIdentified(nick: String; otherNick: String): Boolean;

implementation

procedure init;
begin
	nNicks := 0;
	getMem(nicks, sizeOf(TNick) * nNicks);
end;

procedure done;
var
	I:	Integer;
begin
	for I := 0 to (nNicks - 1) do
		begin
			nicks[I].free;
		end;
	freeMem(nicks);
end;

procedure addNick(data: String);
var
	tokens:	TTokenizer;
	nick:		String;
	hops:		Integer;
	signon:	longInt;
	ident:	String;
	host:		String;
	server:	String;
	unused:	String;
	name:		String;
begin
	tokens := TTokenizer.Create(data);

	nick := tokens.nextToken;
	hops := strToInt(tokens.nextToken);
	signon := strToInt(tokens.nextToken);
	ident := tokens.nextToken;
	host := tokens.nextToken;
	server := tokens.nextToken;
	unused := tokens.nextToken;
	name := strip(tokens.restOfTokens);

	tokens.free;

	inc(nNicks);
	reAllocMem(nicks, sizeOf(TNick) * nNicks);
	nicks[(nNicks - 1)] := TNick.Create(nick, hops, signon, ident, host, server, unused, name);
end;

procedure addNick(data: String; index: Integer);
var
	tokens:	TTokenizer;
	nick:		String;
	hops:		Integer;
	signon:	longInt;
	ident:	String;
	host:		String;
	server:	String;
	unused:	String;
	name:		String;
	tmpNick:	TNick;
	I:			Integer;
begin
	tokens := TTokenizer.Create(data);

	nick := tokens.nextToken;
	hops := strToInt(tokens.nextToken);
	signon := strToInt(tokens.nextToken);
	ident := tokens.nextToken;
	host := tokens.nextToken;
	server := tokens.nextToken;
	unused := tokens.nextToken;
	name := strip(tokens.restOfTokens);

	tokens.free;

	if index < nNicks then
		begin
			tmpNick := backupNick(nick);
			nicks[index].free;
			nicks[index] := TNick.Create(nick, hops, signon, ident, host, server, unused, name);
			copyNickData(tmpNick, nicks[index]);
			tmpNick.free;
		end;
end;

function backupNick(nick: String): TNick;
var
	data:		String;
	tokens:	TTokenizer;
	hops:		Integer;
	signon:	longInt;
	ident:	String;
	host:		String;
	server:	String;
	unused:	String;
	name:		String;
	index:	Integer;
	I:			Integer;
	tmpNick:	TNick;
begin
	index := getNick(nick);

	if index > -1 then
		begin
			data := nicks[index].getData;
			tokens := TTokenizer.Create(data);

			tokens.nextToken;
			hops := strToInt(tokens.nextToken);
			signon := strToInt(tokens.nextToken);
			ident := tokens.nextToken;
			host := tokens.nextToken;
			server := tokens.nextToken;
			unused := tokens.nextToken;
			name := strip(tokens.restOfTokens);

			tokens.free;

			tmpNick := TNick.Create(nick, hops, signon, ident, host, server, unused, name);
			for I := 0 to (nicks[index].numAccess - 1) do
begin
	tmpNick.addAccess(nicks[index].getAccess(I));
end;
			tmpNick.addMode(nicks[index].getModes);
			for I := 0 to (nicks[index].numChannels - 1) do
begin
	tmpNick.addChannel(nicks[index].getChannel(I));
end;
			tmpNick.setUseMsg(nicks[index].getUseMsg);
			tmpNick.setAutoAdd(nicks[index].getAutoAdd);
			backupNick := tmpNick;
		end
	else
		begin
			backupNick := nil;
		end;
end;

procedure copyNickData(srcNick: TNick; destNick: TNick);
var
	I:	Integer;
begin
	for I := 0 to (srcNick.numAccess - 1) do
		begin
			destNick.addAccess(srcNick.getAccess(I));
		end;
	for I := 0 to (srcNick.numChannels - 1) do
		begin
			destNick.addChannel(srcNick.getChannel(I));
		end;
	destNick.addMode(srcNick.getModes);
	destNick.setUseMsg(srcNick.getUseMsg);
	destNick.setAutoAdd(srcNick.getAutoAdd);
end;

function getNick(nick: String): Integer;
var
	I:			Integer;
	index:	Integer;
begin
	index := -1;
	for I := 0 to (nNi

Re: [fpc-pascal]TCollection question

2003-07-06 Thread James Mills
On Sun, Jul 06, 2003 at 05:11:17PM +0200, Marco van de Voort wrote:
> > > IIRC, TCollection only stores TCollectionItem derived classes.
> > > 
> > > TList is closer to what you want probably.
> > 
> > Is there an example other than list.pp in the fcl source ?
> > 
> > Also just for the record of knowing... I have attached datanicks.pas
> > which hold a dynamic array of TNick ... Is this what TList already does
> > (if so I'm wasting my time writing my own code...) ?
> 
> Pretty much yes, but in a class wrapper. You can add and remove items,
> iterate through them etc.  Maybe you can derive a class from TList to
> customize it a bit.

However TList by itself would work though ?

> 
> There are two things to think of:
> - you yourself have to make sure that elements are properly freed, so
>when deleting object A, get a reference to it, delete it from the list, 
>and then free the object. (however that can be automized in the class
>warpper)
Is this all done and automated in TList ?

> - The internal list has two counters, instead of just "nNicks". One
>(capacity) is the reserved space, the other (count) is the amount of
>elements filled. This avoids too many memory fragmenting reallocs.
> (but that's better, not worse)
> 
> I learned to use the classes from code snippets written for  Delphi.
> 
> There is FCL documentation somewhere (and it will be in the next full 
> release), but I couldn't find a recent version so fast.
> 
> So I put down a very old version (April 2002) on the web here:
> 
> www.stack.nl/~marcov/fcl.pdf

I think it's here also in html format:
http://www.nl.freepascal.org/docs-html/fcl/classes/tlist.html

cheers
James

> 
> it at least describes the tlist methods.
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-- 
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


  1   2   3   4   5   6   7   8   9   >