[fpc-pascal] Convert to int64 note
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
>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] Convert to int64 note
>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] Implementing AggPas with PtcGraph
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
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
>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
Re: [fpc-pascal] Windows programming tutorials for FPC
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'); Readln; End; End Else Begin Writeln ('No File Name Specified'); Readln;
Re: [fpc-pascal] Windows programming tutorials for FPC
>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
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_source=link_campaign=sig-email_content=emailclient_term=icon> Virus-free. <https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=emailclient_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
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
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); Assign(TapFile,OutputTapFileName); ReWrite(TapFile); If TapFileHeader.count > 1 then For
[fpc-pascal] Windows programming tutorials for FPC
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
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 not defined in the windows unit (which could > be the case), you can either look into some other units or simply > define it > yourself: >
Re: [fpc-pascal] Windows programming tutorials for FPC
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 >> To: fpc-pascal@lists.freepascal.org >> Subject: Re: [fpc-pascal] Windows programming tutorials for FPC >> >> On 11/03
Re: [fpc-pascal] Windows programming tutorials for FPC
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 Record > lStructSize: DWord; > hWndOwner: HWND; > hInstance: HINST; >
Re: [fpc-pascal] Windows programming tutorials for FPC
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
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
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
[fpc-pascal] Question about fcl-image package
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
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
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
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?
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
Re: [fpc-pascal] Free Pascal 2.4.0 released
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
Oh I see. Thanks Happy New Year!~ 2010/1/3 Florian Klaempfl flor...@freepascal.org 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
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
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 f...@eircom.net To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org 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
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 mar...@stack.nl To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org 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
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
Thank you - will try My computer runs on Windows XP. - Original Message - From: Marco van de Voort mar...@stack.nl To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org 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
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 theres 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
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
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
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
Re: [fpc-pascal] Greetings
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 dougchamber...@earthlink.net 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
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 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
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 jonas.ma...@elis.ugent.be 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
Re: [fpc-pascal]Performance testing of FPC programs?
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
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; ident: String; begin writeLn('What filename? '); readLn(fileName); write('What section? '); readLn(section); write('What ident? '); readLn(ident
[fpc-pascal]Classes/Objects/Pointers
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
[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
Re: [fpc-pascal]Question about fp
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
Re: [fpc-pascal]Slight problem
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]Can I program a linux device driver with fpc?
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...
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
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]Lazarus +FPC
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
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]Strange error with a simple class
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.
Re: [fpc-pascal](Auto) XML Record Loader - Exist?
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= ACTOR COORD X 1 /X Y 2 /Y TCOORD NAME RUI BRENNAN /NAME /ACTOR 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]TCollection question
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 (nNicks - 1) do begin if upperCase(nicks[I].getNick) = upperCase(nick) then begin index := I
Re: [fpc-pascal]TCollection question
On Sun, Jul 06, 2003 at 05:31:59PM +0200, Marco van de Voort wrote: On Sun, Jul 06, 2003 at 05:11:17PM +0200, Marco van de Voort wrote: 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 ? Basically yes. But derive it anyway, in case you want to extend it later. In this case then as I've both read your replies and the webpage about TList I shall extend it :) That'll probably be the best option. Right ? Thanks for your prompt help, I dunno why I'm coding at 0140 in the bloody morning but anyway :) cheers James - 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 ? No. So you have to that yourself. This because TList can also store pointers to records, which don't have to be finalised. So deallocation is still manual. But it is trivial. Assume you want to delete entry 3, assuming that variable TheList is the TList: var t : MyObjectType t:=MyObjectType(TheList[3]); TheList.delete(3); t.free; You can solve it like this: (untested) type tmyTList = class TList public procedure DeleteCompletely(index :Integer); end; procedure tmyTList.DeleteCompletely(index: Integer); var t : MyObjecType; begin t:=MyObjectType(Items[3]); delete(3); if tNIL t.free; end; See TList as a versatile baseclass to quickly build a dedicated, very easy to use container on top of. 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 That's the place I meant yes. ___ 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]TCollection question
Actually Michael, Could you possibly spare 5 mins and give a really simple example of a TList descandent ? I'm a tad confused here, (too slowly getting anywhere)... Thank you :) cheers James ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]TCollection question
On Sun, Jul 06, 2003 at 10:38:28PM +0100, Matt and Lisa Emson wrote: Why not use a TObjectList?? IIRC that is available. In unit Contnrs.pas. It will do a lot more for you. It can 'own' the objects, and therefore free you from needing to manage them. Simple descendent (typed at speed, with no testing): N.B. This is a WRAPPER because it allows the programmer more control over the interface to the class. However a descendent would work the same way pretty much. You'd probably just alter the 'Add' to 'AddXXX' so as to not clash with 'Add' from TList. Otherwise you would hide the method and make in unavailable. This wrapper is really usefull... I use this basic design all the time!! A question about your basic-design and using TList (and descandents in general)... Could I not do this: TMyList = class(TList); . . . And thereby extend the basic TList class into a custom List ? The way you use TList is as a private variable in a generic class. cheers James TMyListItemClass = class; {your class to store} TMyList = class private FList: TList; protected procedure SetItem( Index: integer; Value: TMyListItemClass); function GetItem(Index: integer): TMyListItemClass; public Constructor Create; virtual; Destructor Destroy; override; function Add(AItem: TMyListItemClass): integer; procedure Delete( AIndex: integer ); function Count: integer; property Items[Index: integer]: TMyListItemClass read GetItem write SetItem; end; procedure SetItem( Index: integer; Value: TMyListItemClass); begin FList[Index] := Value; end; function GetItem(Index: integer): TMyListItemClass; begin Result := TMyListItemClass(FList[Index] ); end; Constructor Create; virtual; begin FList := TList.Create; end; Destructor Destroy; override; begin {don't forget some code to empty list} FList.Free; inherited; end; function Add(AItem: TMyListItemClass): integer; begin result := FList.Add(AItem); end; procedure Delete( AIndex: integer ); begin FList.Delete(AIndex); end; function Count: integer; begin Result := FList.Count; end; - Original Message - From: James Mills [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, July 06, 2003 4:56 PM Subject: Re: [fpc-pascal]TCollection question Actually Michael, Could you possibly spare 5 mins and give a really simple example of a TList descandent ? I'm a tad confused here, (too slowly getting anywhere)... Thank you :) 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 -- - - James Mills Zero Defect Software Engineers Group - ZDSEG ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal]FPC Debugging (with SQLite)
Hi, I have a problem with the SQLite library (www.sqlite.org). I believe Michael helped me with the conversion of the headers and the unit that Eric Jourde wrote. This all works fine, however when compiling a program with the debug options (-g, -gg etc), it won't produce any tracebacks of error. It makes it impossible to trace down something like: An unhandled exception occurred at 0x0809911D : List index exceeds bounds (1) 0x0809911D Without the source and line numbers ? (I think perhaps the SQLite library is interferring with the debug symbols in the program? I'm not sure). Any ideas ? 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]FPC Debugging (with SQLite)
On Mon, Jul 07, 2003 at 11:54:38AM +0100, Matt Emson wrote: Eric will have written that unit for BeOS, so I would ask if anyone tested it for other platforms Had a look on BeShare and he's not online, but that is certainly a question that needs to be addressed first. I know he wrote it. I regularly speak to him on MSN. There was a problem with using it, for some reason he didn't need to use the cMem unit back when he wrote the unit. But he had used a very old version of sqlite at the time. I guess the SQLite library has changed dramatically since 2.7... I have tested it on Linux, and the only modification to the unit necessary (I think) is that you have to use the cMem unit. It works quite well and I'll continue to use this for my programs that require an embedded database vs. mysql server. cheers James Matt Hi, I have a problem with the SQLite library (www.sqlite.org). I believe Michael helped me with the conversion of the headers and the unit that Eric Jourde wrote. This all works fine, however when compiling a program with the debug options (-g, -gg etc), it won't produce any tracebacks of error. It makes it impossible to trace down something like: An unhandled exception occurred at 0x0809911D : List index exceeds bounds (1) 0x0809911D Without the source and line numbers ? (I think perhaps the SQLite library is interferring with the debug symbols in the program? I'm not sure). Any ideas ? cheers James -- - - James Mills Zero Defect Software Engineers Group - ZDSEG ___ 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 -- - - James Mills Zero Defect Software Engineers Group - ZDSEG ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]FPC Debugging (with SQLite)
On Mon, Jul 07, 2003 at 03:26:41PM +0100, Matt Emson wrote: How so ? James, he did *not* port this app to BeOS, some one else did. He wrote a Pascal interface to the version that that developer had ported to BeOS (you're following me right ;-). He therefore had no option but to use the version ported under BeOS, unless he ported a newer version himself, right? So therefore, he was only able to do the interface as per the version available to him. Therefore my comment. Do you understand? No trickery involved. Looking at the BeBits page, (http://www.bebits.com/app/3156), 2.7.1 was the last port made (circa November 2002). Now I'm following you. Yes I'm aware that Eric did not actually develop this unit, one of his (people) did. His/Her/It's name is unknown to me. ;) It's been fixed there was no problem with his unit other than the fact that, with the current version of SQLite the cMem unit was needed in order because of the way SQLite uses memory. Cool. Let him know ;-) It should be released in future versions of the FCL according to Michael of FPC :) I can send you a tar.gz of the header translation and the unit though... cheers James ___ 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]New to the list/question
On Wed, Jul 09, 2003 at 03:22:47PM -0500, Kevin Monceaux wrote: Alan, Text based - something that would run on a Linux text console, old dumb terminal, DOS in the days before Windows, etc. I would suggest using nCurses, there is a pascal unit available for this in the FCL I believe. cheers James Kevin On Wed, 9 Jul 2003, Alan Mead wrote: Kevin, Welcome! What do you mean by a text-based interface? -Alan --- Kevin Monceaux [EMAIL PROTECTED] wrote: Pascal enthusiasts, I'm new to the list and just wanted to introduce myself. I got my first tast of Pascal in college on a VAX 11/750 under the VMS operating system. Nowdays Linux is my preferred platform. I was thrilled to discover Free Pascal. It's like becoming reacquanted with an old friend. I have one question. Are there any modules available to easily create text based user interfaces? I know now days everyone prefers GUI interfaces. For quick data entry one can't beat a good old text based user interface. Thanks, Kevin ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal = A Congressman was once asked about his attitude toward whiskey. If you mean the demon drink that poisons the mind, pollutes the body, desecrates family life, and inflames sinners, then I'm against it. But if you mean the elixir of Christmas cheer, the shield against winter chill, the taxable potion that puts needed funds into public coffers to comfort little crippled children, then I'm for it. This is my position, and I will not compromise. __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com ___ 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 -- - - 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 Segfault...
On Thu, Jul 10, 2003 at 05:26:31PM +0200, Marco van de Voort wrote: 15 replace(['0'..'9'], w, s); (gdb) s Program received signal SIGSEGV, Segmentation fault. $08066073 in main () at test4.pas:15 15 replace(['0'..'9'], w, s); (gdb) Passing a set ( ['0'..'9'] ) to procedure replace(search: String; replace: String; var s: String); procedure replace(const chars: array of char; replace: String; var s: String); A string, or a array of char? IMHO it is logical that it crashes? I am passing ['0'..'9'] to a: const chars: array of char; Can't you do this ? If not how else can I rewrite this function ? cheers James ___ 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 NULL Strings...
Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. $ ./test2 Creating class Fields Names --- 0 - channel 1 - owner 2 - regTime 3 - state 4 - URL 5 - email 6 - channelNotice 7 - joins 8 - peak 9 - games 10 - modeLocked 11 - mailLevel 12 - restrict 13 - entries 14 - quota 15 - channelIdle 16 - noIdle 17 - lastSuspension 18 - hideAccess 19 - keepTopic 20 - onChannel 21 - opRestrict 22 - funMsg 23 - mustId 24 - tellAdd 25 - tellDel 26 - tellSet 27 - msgNotice 28 - topic 29 - topicSetter 30 - lastTopic 31 - autoCmd 32 - modes Fields --- 0 - #ProLogiTech prologic 1057934559 REGISTERED1 1 0 0 1 50 0 OFFNO YES YES NO NO NO NO NO NO NO $ ./test3 Creating class Fields Names --- 0 - channelNotice Fields --- 0 - This should be: 0 - Any ideas anyone ? The attached sqlite.pas and sqlitedb.pas were put together by Michael, myself and Eric Jourde (possibly ported from tsqlite I hear) cheers James -- - - James Mills Zero Defect Software Engineers Group - ZDSEG program test2; uses cmem, sqlite,sqlitedb, strings,classes; var MySQL: TSQLite; SQL: String; i,j : Integer; a : TStringList; begin Writeln('Creating class'); MySQL := TSQLite.Create('./channels.db'); MySQL.BusyTimeout := 1000; SQL := 'SELECT * FROM channels WHERE channel LIKE ''#ProLogiTech'';'; MySQL.Query(sql, nil); writeln('Fields Names ---'); for i:=0 to MySQL.List_FieldName.count-1 do writeln(i,' - ',MySQL.List_FieldName.Strings[i]); writeln('Fields ---'); for i:=0 to MySQL.List_Field.count-1 do begin a:=TStringList(MySQL.List_Field.items[i]); write(i,' - '); for j:=0 to a.count-1 do write(a.Strings[j],' '); writeln(''); end; // Uncomment to remove table again. // SQL := 'DROP TABLE Test;'; // MySQL.Query(sql, nil); MySQL.Free; end. program test3; uses cmem, sqlite,sqlitedb, strings,classes; var MySQL: TSQLite; SQL: String; i,j : Integer; a : TStringList; begin Writeln('Creating class'); MySQL := TSQLite.Create('./channels.db'); MySQL.BusyTimeout := 1000; SQL := 'SELECT channelNotice FROM channels WHERE channel LIKE ''#ProLogiTech'';'; MySQL.Query(sql, nil); writeln('Fields Names ---'); for i:=0 to MySQL.List_FieldName.count-1 do writeln(i,' - ',MySQL.List_FieldName.Strings[i]); writeln('Fields ---'); for i:=0 to MySQL.List_Field.count-1 do begin a:=TStringList(MySQL.List_Field.items[i]); write(i,' - '); for j:=0 to a.count-1 do write(a.Strings[j],' '); writeln(''); end; // Uncomment to remove table again. // SQL := 'DROP TABLE Test;'; // MySQL.Query(sql, nil); MySQL.Free; end. channels.db 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; {$ifndef win32} var sqlite_version : pchar;cvar;external; sqlite_encoding : pchar;cvar;external; {$endif} 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
Re: [fpc-pascal]SQLite and NULL Strings...
On Mon, Jul 14, 2003 at 02:26:28PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) is done. in what ? The SQLite library or TStringList ? sqlite. But you said You cannot solve this as long as stringlists are used to contain the data. This made me think it was a behaviour of TStringList ... If it truely is a behaviour of SQLite, I'll get them to change it. You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. How major would the changes be ? Otherwise I'll try and search for a TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda of done something similar in creating a TDatabase descendant..., but it doesn't solve my problem) Implementing a TDataset descendent is not easy, it'll take you at least a week (conservative estimate). Why is this a hard thing to do ? Give me some ideas here, you might be conservative, but I don't muck around :) I'll attach my dbclass.pas a tiny desendant I wrote to simplify using queries (it's centered around making queries simpler)... cheers James Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - - James Mills Zero Defect Software Engineers Group - ZDSEG unit dbClass; interface uses cMem, SQLite, SQLiteDB, Strings, Classes, Functions; type TDatabase = class(TObject) constructor Create; destructor Destroy; override; protected SQL: TSQLite; X: Integer; Y: Integer; S: TStringList; function simpleQuery(query: String): String; function complexQuery(query: String): TStringList; function multiQuery(query: String): TStringList; public end; implementation constructor TDatabase.Create; begin end; destructor TDatabase.Destroy; begin inherited Destroy; if NOT (SQL = nil) then begin SQL.Free; end; end; function TDatabase.simpleQuery(query: String): String; var tmp: String; begin tmp := query; replace('', 'NULL', tmp); writeLn('simpleQuery - ', tmp); if NOT (SQL = nil) then begin SQL.Query(tmp, nil); if (SQL.List_Field.count 0) then begin S := TStringList(SQL.List_Field.items[0]); simpleQuery := S.Strings[0]; end else begin simpleQuery := ''; end; end; end; function TDatabase.complexQuery(query: String): TStringList; var tmp: String; begin tmp := query; replace('', 'NULL', tmp); writeLn('complexQuery - ', tmp); if NOT (SQL = nil) then begin SQL.Query(tmp, nil); if (SQL.List_Field.count 0) then begin complexQuery := TStringList(SQL.List_Field.items[0]); end else begin complexQuery := TStringList.Create; end; end; end; function TDatabase.multiQuery(query: String): TStringList; var temp: String; tmp: String; I: Integer; J: Integer; strs: TStringList; begin temp := query; replace('', 'NULL', temp); writeLn('multiQuery - ', temp); if NOT (SQL = nil) then begin SQL.Query(temp, nil); if (SQL.List_Field.count 0) then begin strs := TStringList.Create; for I := 0 to (SQL.List_Field.Count - 1) do begin tmp := ''; for J := 0 to (TStringList(SQL.List_Field.Items[I]).Count - 1) do begin tmp := tmp + TStringList(SQL.List_Field.Items[I]).Strings[J] + ' '; end; tmp := copy(tmp, 1, (length(tmp) - 1)); strs.add(tmp); end; for I := 0 to (strs.Count - 1) do begin writeLn(I, ' - ', strs.Strings[I]); end; multiQuery := strs; end else begin multiQuery := TStringList.Create; end; end; end; end.
Re: [fpc-pascal]SQLite and NULL Strings...
On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. Where might I find such a descendent that using SQLite ? I'm not quite sure what I'm looking for here... An initial search on google provides some delphi units that are probably not what I'm looking for. 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]SQLite and NULL Strings...
On Mon, Jul 14, 2003 at 03:39:36PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. Where might I find such a descendent that using SQLite ? I'm not quite sure what I'm looking for here... An initial search on google provides some delphi units that are probably not what I'm looking for. On the contrary, on Torry's pages there are some units that do exactly what I described. Ok thanks. I had searched for TDataset descendant sqlite pascal one page came up from Torry's pages. *hits Mozilla, it crashes too much :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]Strange Segfault...
On Mon, Jul 14, 2003 at 06:48:06AM -0700, Alan Mead wrote: I'm running into this string problem as well. I'd like to use strings longer than 255 but I get strange errors like: [EMAIL PROTECTED] seq-bayes]$ fpc mcmc3pl.pas Free Pascal Compiler version 1.0.6 [2002/05/23] for i386 Copyright (c) 1993-2002 by Florian Klaempfl Target OS: Linux for i386 Compiling mcmc3pl.pas Assembling mcmc3pl Linking mcmc3pl mcmc3pl.o: In function `_READ_CONFIG$INTEGER$INTEGER$STRING$STRING': mcmc3pl.o(.text+0x147): undefined reference to `FPC_READ_TEXT_LONGSTR' mcmc3pl.o(.text+0x17c): undefined reference to `FPC_VAL_SINT_LONGSTR' mcmc3pl.o(.text+0x243): undefined reference to `FPC_READ_TEXT_LONGSTR' mcmc3pl.o(.text+0x278): undefined reference to `FPC_VAL_SINT_LONGSTR' mcmc3pl.pas(215) Error: Error while linking Closing script ppas.sh [EMAIL PROTECTED] seq-bayes]$ fpc test_string500 Free Pascal Compiler version 1.0.6 [2002/05/23] for i386 Copyright (c) 1993-2002 by Florian Klaempfl Target OS: Linux for i386 Compiling test_string500.pas test_string500.pas(15,13) Fatal: Internal error These errors disappear when I edit the string definitions back to length 255 or less. Should I just avoid using longer strings or is there a compiler switch I have to include? Or is there a tutorial on FPC strings (I never used Delphi much)? Or is this behavior fixed in 1.0.10? I believe there is a compiler switch. cheers James -Alan --- Matt Emson [EMAIL PROTECTED] wrote: Yes and no. Why is it so bad to write a function in that way ? It could of course be written two different ways, but I'd rather this way where I modify the string passed to the function. Explain it to me :) (I'm the only one that works on this project of ~30,000 LOC, so I don't see any problem) Turbo Pascal and Delphi 1 had a type called 'String'. This was limited to 255 chars, size of 256 chars, and position 0 holds the strings length. Delphi 2+ has a type called shortstring that behaves in exactly the same way as the old style string. Delphi 2+ altered the string type to be a pointer to a chunk of memory, and added a whole load of compiler magic to make strings automatically grow and shrink, added reference counting and 'copy of change' functionality (the last two to aid in not having to copy a string until someone alters it.) This is where your problem lies. Because FPC mimics Delphi string functionality, basically you'll end up with similar results. You'd be much better off Returning a value, and thereby avoiding the potential for big allocation/deallocations. That or use shortstrings. Matt ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com ___ 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]SQLite and NULL Strings...
On Mon, Jul 14, 2003 at 03:06:44PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 02:26:28PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) is done. in what ? The SQLite library or TStringList ? sqlite. But you said You cannot solve this as long as stringlists are used to contain the data. This made me think it was a behaviour of TStringList ... If it truely is a behaviour of SQLite, I'll get them to change it. The problem is that there is no way to distinguish between a 'null' and an empty string once it is converted to a string. The information is simply lost. Just reconfirming with you and solidifying my knowledge. The reason it returns is because: when working with native pascal types, assigning null to a string results in an empty string right ? cheers James You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. How major would the changes be ? Otherwise I'll try and search for a TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda of done something similar in creating a TDatabase descendant..., but it doesn't solve my problem) Implementing a TDataset descendent is not easy, it'll take you at least a week (conservative estimate). Why is this a hard thing to do ? Give me some ideas here, you might be conservative, but I don't muck around :) Because TDataset is not an easy subject. You need to implement a lot of calls in a correct and predefined way. 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]SQLite and NULL Strings...
On Tue, Jul 15, 2003 at 07:04:05AM -0700, Alan Mead wrote: --- James Mills [EMAIL PROTECTED] wrote: On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote: --- James Mills [EMAIL PROTECTED] wrote: Just reconfirming with you and solidifying my knowledge. The reason it returns is because: when working with native pascal types, assigning null to a string results in an empty string right ? cheers James James, Pascal is a strongly typed language and there is no Pascal string precisely equivalent to a NULL. Someone (either the SQLite authors or the one who wrote the Pascal wrapper) decided to automatically translate NULL into empty (zero-length) strings. And it's impossible now to distinguish actual null values from fields containing actual zero-length strings. I think I'm slowly understanding this bit now. I don't claim to be an SQL expert. But SQL (sqlite anyway) is capable of storing any data types, strings, integers, boolean etc, including NULL values. I hope I'm correct here... I know nothing specifically about SQLite but SQL has many data types, similar to Pascal. However, SQL data fields can also have the value NULL which has no analog with Pascal data. Pascal data types cannot simultaneously hold data and this non-data missing value code (unless you define some convention within your code... like you could arrange for NULL results to be returned as the string value 'NULL' but then you would be unable to distinguish between actual strings with the value 'NULL' and the NULL result... which may be no big deal). According to Michael, someone arranged for NULL values to be translated to empty strings, perhaps without even meaning to, because of how ansistrings act.. they are internally pointers and an empty string is represented as a nil pointer. I have no idea why this behavior would be different between Windows (?) and Linux. (in fact, are you sure it is?) Why could I not simply check for '' in my sql return functions and simply return '' instead (a pascal empty string) ? Would this be terribly wrong ? See below. Or am I still going to have to follow Michael's suggestion in finding a TDataset desendant ? (I don't understand what a TDataset desendant really is and why I need to use one but anyway...) I think the idea with the TDataset was to create a record in Pascal that could hold all the SQL data. Since a string alone cannot hold it, you need a record with a string and a boolean. The boolean holds NULL or not-NULL. When the boolean holds not-NULL, the string holds the data (the string should never hold data if the boolean hold NULL). By boolean holds NULL, of course, I mean that you define the boolean in some way so that it indicates the NULL-ness. For example, define it as 'IsNull:boolean;' and then TRUE will indicate that the result is NULL. Why did Michael say that creating a TDataset was so hard ? If in it's simplest form it's just a record to hold the data with a boolean indicating it's null-ness, that doesn't seem so difficult to implement to me. I might play around with the mysqldb.pp dataset class in the fcl source though... 3) you could simply avoid ever having empty strings in your database (in which case, empty strings returned are always NULL's) There should be no empty string in my database anyway. If a field is empty it's value is NULL. Well then why are you worried about distinguishing between NULL's and empty strings? All empty strings are NULL's. (I know originally, you were compiling test programs... is this really an issue?) My program relies on the fact that some fields (which are string types) are null. I'm not sure what to say next so I'll leave it at that :P cheers James -Alan __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com ___ 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]SQLite and NULL Strings...
On Tue, Jul 15, 2003 at 05:27:42PM +0200, Michael Van Canneyt wrote: On Wed, 16 Jul 2003, James Mills wrote: On Tue, Jul 15, 2003 at 07:04:05AM -0700, Alan Mead wrote: --- James Mills [EMAIL PROTECTED] wrote: On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote: --- James Mills [EMAIL PROTECTED] wrote: Just reconfirming with you and solidifying my knowledge. The reason it returns is because: when working with native pascal types, assigning null to a string results in an empty string right ? cheers James James, Pascal is a strongly typed language and there is no Pascal string precisely equivalent to a NULL. Someone (either the SQLite authors or the one who wrote the Pascal wrapper) decided to automatically translate NULL into empty (zero-length) strings. And it's impossible now to distinguish actual null values from fields containing actual zero-length strings. I think I'm slowly understanding this bit now. I don't claim to be an SQL expert. But SQL (sqlite anyway) is capable of storing any data types, strings, integers, boolean etc, including NULL values. I hope I'm correct here... I know nothing specifically about SQLite but SQL has many data types, similar to Pascal. However, SQL data fields can also have the value NULL which has no analog with Pascal data. Pascal data types cannot simultaneously hold data and this non-data missing value code (unless you define some convention within your code... like you could arrange for NULL results to be returned as the string value 'NULL' but then you would be unable to distinguish between actual strings with the value 'NULL' and the NULL result... which may be no big deal). According to Michael, someone arranged for NULL values to be translated to empty strings, perhaps without even meaning to, because of how ansistrings act.. they are internally pointers and an empty string is represented as a nil pointer. I have no idea why this behavior would be different between Windows (?) and Linux. (in fact, are you sure it is?) Why could I not simply check for '' in my sql return functions and simply return '' instead (a pascal empty string) ? Would this be terribly wrong ? See below. Or am I still going to have to follow Michael's suggestion in finding a TDataset desendant ? (I don't understand what a TDataset desendant really is and why I need to use one but anyway...) I think the idea with the TDataset was to create a record in Pascal that could hold all the SQL data. Since a string alone cannot hold it, you need a record with a string and a boolean. The boolean holds NULL or not-NULL. When the boolean holds not-NULL, the string holds the data (the string should never hold data if the boolean hold NULL). By boolean holds NULL, of course, I mean that you define the boolean in some way so that it indicates the NULL-ness. For example, define it as 'IsNull:boolean;' and then TRUE will indicate that the result is NULL. Why did Michael say that creating a TDataset was so hard ? If in it's simplest form it's just a record to hold the data with a boolean indicating it's null-ness, that doesn't seem so difficult to implement to me. It is not that, it's much more than that. TDataset manages such 'records' and much more. You can write whole books about the TDataset class and it's descendents. I wouldn't advise someone with no experience with TDatasets to start writing a descendent. You obviously know a lot about this topic as I've seen in the mysql dataset you created and the generic dataset. I've looked at it and shaken my head! (I'll admit I don't know a lot about databases, but am learning, SQL is my only knowledge thus far). Having said that though, I'm going to try and modify Eric Jourde's sqlite unit to accomadate for NULLs (try being the operative word :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]SQLite and NULL Strings...
On Tue, Jul 15, 2003 at 08:35:44AM -0700, Alan Mead wrote: --- James Mills [EMAIL PROTECTED] wrote: My program relies on the fact that some fields (which are string types) are null. I'm not sure what to say next so I'll leave it at that :P If your database never contains an empty string, then your program can rely on the empty strings you retrieve being NULL values in the database. This case is true and the database will never contain empty strings only NULL values. The program has strict ways of doing this, unless of course you modify the databases externally, then bam (you're right as per below)... cheers James But if an empty string ever crept into a database field, then your program would think the field is null when it's not. If this would cause a grevious error, then you should find a better way. -Alan __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com ___ 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]SQLite and NULL Strings...
On Tue, Jul 15, 2003 at 08:53:12AM -0700, Alan Mead wrote: --- James Mills [EMAIL PROTECTED] wrote: On Tue, Jul 15, 2003 at 08:35:44AM -0700, Alan Mead wrote: --- James Mills [EMAIL PROTECTED] wrote: My program relies on the fact that some fields (which are string types) are null. I'm not sure what to say next so I'll leave it at that :P If your database never contains an empty string, then your program can rely on the empty strings you retrieve being NULL values in the database. This case is true and the database will never contain empty strings only NULL values. The program has strict ways of doing this, unless of course you modify the databases externally, then bam (you're right as per below)... So if you do nothing, your program will work unless someone accesses the database externally (or there is a bug in whatever code ensures against inserting empty strings). You need to decide how likely and bad that is. Well the only bad thing is that it returns data where there should be no data. ie: '' instead of the expected '', causing the program to treat '' as if it were a real string. James But maybe there is a simple work-around. Surely you can execute SQL select statements using SQLite, right? If so, then you can exploit the fact that SQL itself is well aware of the distinction between empty strings and NULL's to check for this error condition. If you're checking one table called MYTABLE with a key called IDX and a couple fields to check are ADDRESS1 and ADDRESS2 then you would execute this select: select IDX from MYTABLE where ADDRESS1='' or ADDRESS2='' If you get no results, then there is no error condition (you can safely assume empty strings are NULL's). If you get any results, then you know which records need to be fixed. You could execute this query at the start of your application's run. Or you could run it periodically (e.g., nightly) and email yourself the results. -Alan __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com ___ 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]Synapse for FPC
On Tue, Jul 22, 2003 at 10:36:54AM +0200, Lukas Gebauer wrote: Why should we use your set of classes vs. another set of classes developer by person X ? :) Just a friendly question, I know there are a lot of TCP/IP suites around... Why? It is not simple question. ;-) Before a five years I need socket library for Delphi. In this time exists only two good libraries.. ICS (but it is using asynchronous sockets) and Winshoes (now it is called Indy). Yes, exists other libraries, but only this will be freeware and opensource! For my purposes indy looks good. but it is components. You must do lot of things for install them to your system, etc. Indy is very huge and slow library. And on mostly places it is very badly written. ;-( Rather then using it I wrote my own library based only on units with non- visual classes. It not need instalation, only add my unit to your 'uses' and go! When my fiend from Delphree association see my work, then tell me: get your library for public, it is great! Synapse was born! By some years I create simple and fast implementation for lot of commonly used protocols. Synapse is not only one of TCP/IP libraries, this is technology leader. ;-) Yes, for example, Indy using lot of code based on my Synapse now! Synapse is first free and opensource library with solutions for email with automatic translating of charsets, Synapse is first free library with native SNMP implementation, Synapse is first free library with 'instant' IPv6 support, Synapse is first free library with native LDAP client, etc. Yes 'First free' in delphi world! But on FPC world I not see comparable TCP/IP library. Really lot of people asking me: Exists Synapse for FPC? FPC world now can use five years experience with Synapse from delphi world. ;-) You've convinced me :) Thanks for creating this suite... cheers James -- Lukas Gebauer. E-mail: [EMAIL PROTECTED] WEB: http://www.ararat.cz/synapse - Synapse Delphi and Kylix TCP/IP Library ___ 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]Synapse for FPC
On Tue, Jul 22, 2003 at 09:28:12AM +0200, Michael Van Canneyt wrote: On Tue, 22 Jul 2003, Marco van de Voort wrote: SNMP, NTP, SNTP, DNS, Syslog, FTP, TFTP, HTTP or LDAP protocols. You can also use my MIME encoding and decoding engine, you can use my charset transcoding engine... and lot of more stuffs. ;-) For more informations look to 'Ararat Synapse' web. Why should we use your set of classes vs. another set of classes developer by person X ? :) That's clear I think. It works with FPC :-) Yes. I've been cooperating to get it to work with FPC. It's one of the few suites that doesn't require threads and/or message pumps. So it was better suited to work with FPC, till we have sufficient support for threads and the like. (scheduled for 1.2) Good :) The more FPC stuff out there the better I say, it's a bloody beautifull compiler of a very nice old language! 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]XChat plugins using FPC
Hi, I can successully compile and test the plugin source listed at http://xchat.org/docs/plugin20.html written in C. However I don't like C much and am wondering if it's possible to do the same thing in pascal... ? I know it has to be possible, but I need someone to start me off in the right direction... 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]XChat plugins using FPC
On Fri, Jul 25, 2003 at 01:04:14PM +0200, Holger Peters wrote: Hi, if you are successful, I would be glad to receive the ported Header files and a small example. rofl! :) Make me do all the hard work :( This is the first time I've converted any c headers of any sort... I'm getting close though I think I'll end up writing a unit interface to the c functions though. I don't want to end up writing plugins and having to remember every bloody xchat interface command :) do you ? cheers James Holger James Mills schrieb: Hi, I can successully compile and test the plugin source listed at http://xchat.org/docs/plugin20.html written in C. However I don't like C much and am wondering if it's possible to do the same thing in pascal... ? I know it has to be possible, but I need someone to start me off in the right direction... cheers James ___ 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]A suggestion.
On Fri, Jul 25, 2003 at 10:33:19AM +0200, Jonas Maebe wrote: On vrijdag, jul 25, 2003, at 08:30 Europe/Brussels, A.J. Venter wrote: I miss being able to put the cursor on a function/procedure/reserved word name and hitting F1 to see the help section for it. The text mode IDE already has support for this (using the html documentation). I use to use borland's turbo pascal ide once too, but I don't miss this feature :) Nowadays vim suits be better cheers James Jonas ___ 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]runtime 201 with swapword function
On Fri, Jul 25, 2003 at 04:21:36PM +0200, Jonas Maebe wrote: On vrijdag, jul 25, 2003, at 16:22 Europe/Brussels, James Mills wrote: Why does the following result in a runtime error ? program example; const THE_PORT = ; function swapWord(w: Word): Word; begin swapWord := (w SHL 8) OR (w SHR 8); end; In Pascal, all calculations are performed using the base type (which is longint in FPC), so if w 255, then w shl 8 high(word) and will result in a range check error when assigning to swapWord. Even if we calculated everything using words, you'd still get an overflow error, this time when doing the shl. How can I correct this ? This bit of code was taken directly from server.pp in one of the old 2002 mailing threads... cheers James Jonas ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]runtime 201 with swapword function
On Fri, Jul 25, 2003 at 04:30:35PM +0200, Florian Klaempfl wrote: James Mills wrote: On Fri, Jul 25, 2003 at 04:21:36PM +0200, Jonas Maebe wrote: On vrijdag, jul 25, 2003, at 16:22 Europe/Brussels, James Mills wrote: Why does the following result in a runtime error ? program example; const THE_PORT = ; function swapWord(w: Word): Word; begin swapWord := (w SHL 8) OR (w SHR 8); end; In Pascal, all calculations are performed using the base type (which is longint in FPC), so if w 255, then w shl 8 high(word) and will result in a range check error when assigning to swapWord. Even if we calculated everything using words, you'd still get an overflow error, this time when doing the shl. How can I correct this ? This bit of code was taken directly from server.pp in one of the old 2002 mailing threads... Turn range checking off for this piece of code or do function swapWord(w: Word): Word; begin swapWord := ((w SHL 8) OR (w SHR 8)) and $; end; Least now I know the reason :) cheers James ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]How to use Linux libraries?
On Fri, Jul 25, 2003 at 06:18:48PM +0200, Rainer Hantsch wrote: Hello, James! On Sat, 26 Jul 2003, James Mills wrote: | I could write you up a set of such procedures or classes to do this, | however I'm starting back at uni. New semester :) Good success at Uni! What are you studying? Bachelor of Engineering in Software Engineering at Griffith University (Australia, QLD) | Anyway, I'm sure there are others here on this mailing list that could | do the same. Possibly, yes. But you are the _first_ one who answered, so the number of people still seems to be very small... ;-) | Question: Why can't you do it yourself ? It isn't that hard to grab the | specs of the JPEG image format and learn it and write your own data | structures to contain the jpeg image data, decode it into pixel arrays... | It's all there in the specs :) Something about me: I started programming in Pascal roughly 15 years ago, on CP/M (Z80 CPU, 4MB RAM, 10MB HDD,...), later I changed to DOS with finally Borland Pascal, but I kept consequently away from Windoze programming. Finally I changed to Linux, which is more what I like DOS, than Windoze... But all this years I never wrote one line in assembly language, nor was there any need for me to include external code. I did everything in plain Pascal language, without any hacking and tweaking, which was perfect for writing all this userspecific software. So my primary problem is that I never got experience about how to solve such things like linking to external libraries. Of course, I could sit down and hope to find it out by myself with trial error, but this is extremely inefficient and time consuming. Also success will be very low in this case. Another thing is: Why should I start re-inventing the wheel and writing my own JPEG/TIFF/.../units from scratch, when there exist a lot of ready made libraries? Isn't it the purpose of libraries to do exactly this? So I am looking for some help in form of _working_ samples which I can analyze and try to understand. It will also be very helpful if there would be somebody who could teach me a little bit and guide me to my first success. As you'll read in other posts just recently there are jpeg units for pascal that do this. I probably have some myself that I'm unaware of :) cheers James mfg Ing. Rainer Hantsch ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]runtime 201 with swapword function
On Fri, Jul 25, 2003 at 04:36:39PM +0100, Matt Emson wrote: Doesn't system contain a routine called 'swap' that does this exact thing?? This program would seem to work in both Delphi and FPC1.1: program test; {$APPTYPE CONSOLE} uses sysutils; var i, j: word; begin i := $9988; writeln( IntToHex(i, 4) ); //output '9988' j := swap( i ); writeln( IntToHex(j, 4)); //output '8899' readln; end. No need to go to the trouble of writing your won routine!! ;-) I didn't write it, one of the FPC developers did last year in the mailing list :) cheers James Matt Hi, Why does the following result in a runtime error ? program example; const THE_PORT = ; function swapWord(w: Word): Word; begin swapWord := (w SHL 8) OR (w SHR 8); end; var port: Word; begin port := swapWord(THE_PORT) end. $ ./swapword Runtime error 201 at 0x08052AA2 0x08052AA2 0x08052AC2 0x080480B0 cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ 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 -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal]Cross-Compiling
Hi, How are you guys goins with crosscompiling ? I'd like to be able to cross compile from Debian/Linux to various other platforms... Or have you been crosscompiling the other way ? Anyone attempted to write a howto/tutorial yet ? cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Cross-Compiling
On Fri, Aug 01, 2003 at 10:45:00PM +0300, Nikolay Nikolov wrote: James Mills wrote: How are you guys goins with crosscompiling ? I'd like to be able to cross compile from Debian/Linux to various other platforms... Or have you been crosscompiling the other way ? First of all, you need binutils, compiled with support for the targets you want. Get the source, read the docs, and enable the targets you want, then compile it. It's C, so you need gcc environment. http://www.gnu.org/directory/GNU/binutils.html If you manage to compile the binutils successfully you should end up having as, ld, strip, etc... that support your target os cpu. You could also try looking for some precompiled binaries of the binutils, for the target you want. After that you can do: ppc386 -Tyour_target_os -FD/path_to_cross_binutils yourfile.pas You also need the Free Pascal RTL (and other OS-specific units), you can get them precompiled from the fpc website. They are part of the fpc binary distribution for your target os. Thank you for this information, I now have more of an insight of how it's done :) cheers James ... or you can compile them yourself using the fpc source, but that's somewhat more complicated. If you want to compile for another cpu (fpc 1.0.10 supports i386 and m68k; fpc 1.1 currently supports i386, powerpc and sparc) then you *must* compile the compiler. You can read the fpc docs, for compiling the compiler... :) IIRC it was something like make CPU_TARGET=m68k in the compiler dir for the motorola 680x0 (ppc for powerpc, i386 for i386, sparc for sparc :) )... You end up having a ppc68k executable. Then you go to the rtl directory and compile the rtl using this new ppc68k make PP=ppc68k OPT=-FD/path_to_cross_binutils Perhaps you also need to add OPT=-Tyour_target_os... I did it 2 weeks ago (I compiled a crosscompiler for m68k amiga), and this is what I remember... There might be some mistakes here... just read the docs, read the fpc compiler options and play with it, until you get it working... :) And you're done. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Direct writes to console buffer
On Sun, Aug 03, 2003 at 02:52:57AM -0400, L D Blake wrote: In reply to your message of August 3, 2003 I'm trying to port some old Turbo Pascal programs to Windows 32-bit console utilities. They write directly to the screen buffer, which in the DOS world an array of Word starting at ptr(SegB800,0) (for a color display) or ptr(SegB000,0) for a monochrome one. Now, as Windows console utilities, I don't suppose it's so easy to get a pointer to the upper left corner of the console window, or is it? There's an additional complication... ME, NT, 2000 and XP won't let you write directly to the screen memory. You'll probably need to re-work the screen access to use the through-the-drivers approach unless you are only interested in having your stuff work on 95 and 98. In addition, I suggest using SDL which will work for windows. SDL is probably a much better approach than trying to directly access video RAM. And to makes things easier for you, once you learn to use SDL, you could write a wrapper module so you don't have to even rewrite your old programs :) cheers James - L D Blake ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Direct writes to console buffer
On Sun, Aug 03, 2003 at 07:26:35AM -0700, Rich Pasco wrote: James Mills wrote: In addition, I suggest using SDL which will work for windows. SDL is probably a much better approach than trying to directly access video RAM. And to makes things easier for you, once you learn to use SDL, you could write a wrapper module so you don't have to even rewrite your old programs :) What is SDL? Where can I get documentation about it? Google turned up Simple DirectMedia Layer -- http://www.libsdl.org/ -- is that what you meant? Yes this is the SDL Library. There is also an FPC port of this library (version 1.2.0.0). I cannot find the home page for it though, so if you can't find it also, I'll mail it to you. Also I don't think there are any suitable tutorials (The ones provided in the FPC port aren't that great) for using SDL with FPC except for the C documentation at the libsdl website and others you may find. cheers James It could also be Specification and Description Language -- http://www.sdl-forum.org/SDL/ -- but that seems less likely. Not this. - Rich ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Error 216 with SDL
On Mon, Aug 04, 2003 at 09:12:37PM +0200, Holger Peters wrote: Hi, I used SDL4FreePascal under Windows with FreePascal 1.0.6 and it worked fine. Now, I use RedHat 9.0 with FreePascal 1.0.10 and SDL4FreePascal doesn't work. When I compile the demos, I get the runtime error 216 at the first SDLcommand. I used to get this runtime error a lot using FPC 1.0.6 running Debian... I can't remember what the cause was though or the solution :P When I do I'll let you know :) Is there a solution? All I can suggest is to debug the code, I believe the demos themselves aren't that good. cheers James Holger ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Error 216 with SDL
On Mon, Aug 04, 2003 at 09:44:13PM +0200, Jonas Maebe wrote: On maandag, aug 4, 2003, at 21:12 Europe/Brussels, Holger Peters wrote: I used SDL4FreePascal under Windows with FreePascal 1.0.6 and it worked fine. Now, I use RedHat 9.0 with FreePascal 1.0.10 and SDL4FreePascal doesn't work. When I compile the demos, I get the runtime error 216 at the first SDLcommand. Is there a solution? The problem may be that the SDL4FreePascal C-header translation was done for an older version than what you have now, so that type and function definitions are wrong now. There are two possible solutions: a) install the same version of SDL on your system as what you were using before b) translate the SDL headers of the new version to Pascal (or bug someone else to do it :) Thanks Jonas :) I was clueless :P James Jonas ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]SQLITE with FPC
On Wed, Aug 06, 2003 at 07:18:33PM +0200, Jilani Khaldi wrote: Hi All, could someone point me where to find the sqlite.pas for FP to use with Linux Linux? Any hint or examples is welcome. jilani Let me know if you find a TDataSet class that'll work with FPC and Sqlite on Linux. Cause I haven't yet... There are some around on torry.net but they're for delphi using windows. I've asked the author if he could convert it to FPC for linux but without much luck atm. I say this because you're going to run into pascal string problems like I have. cheers James ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]what Programming Environment : Editor Debugger
On Thu, Aug 07, 2003 at 12:32:59AM +0200, Stefan Becker wrote: dear Pascal'ers, I've just searched the net and freepascal.org in the hope of finding some info on what and how to set up a working environment with linux. So far I've done all my editing and debuging on a DOS machine with Borland 7.0 - and just recompiling my applications with freepascal for linux. I want to go to a pure linux environment - so now the question. What editor or program should I use and work my way into? It would be nice to have a debugger also. Is there any finished packages that I could use? The FreePascal website talks about a fp IDE and I remember seeing it for DOS. Does this exist for linux? vim is a nice text editor for sources and support pascal syntax highlighting. I think there is an IDE for Linux though, you'll find it on the Free Pascal website. There's also Lazarus that'll you find as well which you can use. It's similar in many ways to Delphi and can be used for all your development and gui needs (though I have not used it yet). As far as a debugger goes, simply use gdb. cheers James many thanks, Stefan Becker ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal]Debuggin
Hi, 1) Is there anyway of finding out the cooresponding source line when a program crashes and only outputs the following: An unhandled exception occurred at 0x080A33B1 : List index exceeds bounds (-1) 0x080A33B1 2) With compile modes: -gg -gl Aren't line info and tracebacks suppose to be shown, the above example does not show these. cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal]Debugging FPC
I think perhaps I need to repost my question as I saw the mailing list server go down yesterday... Hi, 1) Is there anyway of finding out the cooresponding source line when a program crashes and only outputs the following: An unhandled exception occurred at 0x080A33B1 : List index exceeds bounds (-1) 0x080A33B1 2) With compile modes: -gg -gl Aren't line info and tracebacks suppose to be shown, the above example does not show these. cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]RE: Debugging FPC
On Thu, Aug 21, 2003 at 09:44:30PM -0700, Jeff Pohlmeyer wrote: With compile modes: -gg -gl Aren't line info and tracebacks suppose to be shown, the above example does not show these. I think the problem comes with using exceptions. Normally, if a run-time error occurs, the default exit proc will print the line number info to stdout. But if an exception traps the error before the program exits, then that information is absorbed by the exception handler, and never makes it to the exit proc. I do not have any exception handlers in my program though... So how does it not show the line number info ? cheers James __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Debugging FPC
On Fri, Aug 22, 2003 at 11:08:14AM +1000, James Mills wrote: I think perhaps I need to repost my question as I saw the mailing list server go down yesterday... Hi, 1) Is there anyway of finding out the cooresponding source line when a program crashes and only outputs the following: An unhandled exception occurred at 0x080A33B1 : List index exceeds bounds (-1) 0x080A33B1 Also anyone out there, I'd really like to know if the above is possible ... I have to find the source of this particular defect in 19,000 LOC. All it tells me is an index out of bounds, which could mean a number of things. Thanks in advance James 2) With compile modes: -gg -gl Aren't line info and tracebacks suppose to be shown, the above example does not show these. cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Debugging FPC
On Fri, Aug 22, 2003 at 09:30:49AM +0200, [EMAIL PROTECTED] wrote: On Fri, 22 Aug 2003, James Mills wrote: An unhandled exception occurred at 0x080A33B1 : List index exceeds bounds (-1) 0x080A33B1 Also anyone out there, I'd really like to know if the above is possible ... I have to find the source of this particular defect in 19,000 LOC. All it tells me is an index out of bounds, which could mean a number of things. Load the program in gdbpas. Put a breakpoint on HandleErrorFrame (with the what is gdbpas ? I'm using FPC 1.0.6 ... cheers James command b HANDLEERRORFRAME, caps are important). You can set command line parameters using set args para1 para2 If not all of the sources are in one directory, you can add directories that gdbpas has to search sources in using directory dir1;dir2;dir3; Next, type run. When the breakpoint is hit, type bt (backtrace). Jonas ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Debugging FPC
On Fri, Aug 22, 2003 at 10:35:15AM +0200, [EMAIL PROTECTED] wrote: gdbpas is included with fpc (all versions). gdb = GNU DeBugger. The pas stands for with pascal extensions. I do not seem to have this anywhere on my system. Of course I have gdb. Can I get it somewhere ? (Perhaps the Debian maintainer didn't include it in 1.0.6) PS: please only quote the part of the original mail that's necessary to understand the context. nps, sorry, putting into practise now :) -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Debugging FPC
On Fri, Aug 22, 2003 at 03:14:20PM +0200, Peter Vreman wrote: You can use the gdb available in Debian. It has already the pascal support included. (gdb) b HANDLEERRORFRAME Function HANDLEERRORFRAME not defined. It doesn't define whatever HANDLEERRORFRAME is though, so what Jonas said won't work... cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]TStringList.indexOf (case-sensitivity)
On Wed, Aug 27, 2003 at 03:03:31PM +0200, Michael Van Canneyt wrote: On Wed, 27 Aug 2003, James Mills wrote: On Wed, Aug 27, 2003 at 09:39:10AM +0200, Michael Van Canneyt wrote: On Wed, 27 Aug 2003, James Mills wrote: Hi, Is TStringList.indexOf case sensitive or insensitive ? TStrings.indexOf is case insensitive, but TStringList.indexOf overrides the TStrings.indexOf implementation accoriding to the documentation. It is case insensitive, but this was changed recently for Delphi compatibility. Older versions are case sensitive. Here are the relevant log entries: revision 1.15 date: 2003/05/29 23:13:57; author: michael; state: Exp; lines: +5 -2 fixed case insensitivity of TStrings.IndexOf revision 1.14 date: 2002/12/10 21:05:44; author: michael; state: Exp; lines: +12 -5 + IndexOfName is case insensitive Is there no other function that searches the list in a case insensitive way ? I've been looking through the current FCL source and speaking to a member of the list... No. IndexOf() is meant to search the list. In D7, there is a property 'CaseSensitive' which determines whether the search is performed case sensitively or not... I look at the source and didn't see a property like this. Maybe I'll check again :) So if I went, strings.CaseSensitive := True; it'd work ? It seems perhaps I should write a descendant of TStringList, which I've done and works for my purpose. This is always possible, that is why we have OOP. The other query I have with TStringList, is the sqlite unit uses CommaText which replaces with and other side affects you don't want in an IRC Services application. Then you don't need commatext, but plain old 'text'. The idea of commatext is exactly that it replaces with ... Well I've left the sqlite class to use commatext, but in my simple database class have used nsiExtractQuotedStr to remove double quotes and surrouding quotes in the string. using plain text adds extra 0A chars on the end. cheers James Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Lazarus
On Thu, Aug 28, 2003 at 04:08:44PM +0200, Marco van de Voort wrote: The www.lazarus.freepascal.org has been down for a while, does anyone know what exactly what happened? Some hacker activity, and the owner wanted to reinstall to make sure that they were entirely gone. That's so pathetic. What'd the hacker do anyhow ? And how the heck does a hacker break into a *nix box ? (I assume it is...) cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Read from command line
On Sun, Sep 07, 2003 at 09:43:32PM +1000, DONALD PEDDER wrote: Don't know if it's different in Linux, but in the DOS version at least you can use paramstr(1), paramstr(2), etc. if (paramstr(1)='test') then writenln('you passed the parameter passing test') It isn't any different on Linux: paramCount (returns the number of parameters passed to the program) paramStr(i) (returns the i'th parameter) cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal]SDL Library
Hi, What's the reccomended SDL library to use with FPC ? With FPC 1.0.6 I used to use SDL4Freepascal-1.2.0.0.tar.gz by Daniel F Moisset ... Are there any further updates to SDL for use with FPC ? I found Daniel's port of the SDL library very easy to use. cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal]cgiapp.pp and ezcgi.pp possible bug
Hi, I think there might be a possible bug in both ezcgi.pp and cgiapp.pp If you try and post a piece of form data: ie: textarea /textarea it will hang in an infinite loop. I'm not sure where the problem is, debugging cgi apps is hard ;) cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]make files
On Sun, Sep 07, 2003 at 04:30:39PM -0400, Frank W McCormick wrote: Hi all Can someone give me a simple example of a makefile suitable for just simple compiling of one file ? I am so used to running FPC from the command line that make is foreign to me. Catch! cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. psb=psb.pas all: psb psb: $(psb) fpc $(psb) debug: $(psb) fpc -bl -gg $(psb) clean: rm -f *ppu* *.o psb *~
[fpc-pascal]CGI: cgiapp.pp and ezcgi.pp possible bug
Hi all again, I'm reposting this question as I would like to find some answers to this problem, or writing this particular kind of CGI App will be impossible. (Forum). I think there might be a possible bug in both ezcgi.pp and cgiapp.pp If you try and post a piece of form data: ie: textarea /textarea it will hang in an infinite loop. I'm not sure where the problem is, debugging cgi apps is hard ;) cheers James -- - -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal