[Lazarus] [SOLVED] Re: [fpc-pascal] ord() of a string index returns wrong value.
Hi Jonas, [ and cross-posted to lazarus-list ] On 01/30/2011 04:59 AM, Jonas Maebe wrote: On 29 Jan 2011, at 18:34, Pew (piffle.the.cat) wrote: On 01/30/2011 03:13 AM, Jonas Maebe wrote: On 29 Jan 2011, at 17:05, Pew (piffle.the.cat) wrote: I have a problem where ord() of a character (single string index) returns the wrong value. the character is a 'o' which is a 111 value but the ord of it returns 121 into an integer. What am I doing wrong? Is that Lazarus code? If so, the string will be utf-8 encoded and you cannot assume that str[i] corresponds to the i'th character of the string. Even if it's not Lazarus code, it could still be utf-8 encoded depending on what the source of the string is and/or the locale settings of the system. Yes, it is Lazarus code. Okay so I think that we have found the problem. Now how do I fix it? If you want to access individual characters, it's probably the easiest to convert it to a unicodestring first: var utxt: unicodestring; begin .. utxt:=utf8decode(txt); { now perform all operations on utxt instead of on txt } .. end; I will use this code (listed above) in preference to the latter code, as you state the latter code has a higher probability of data loss. Note: 1) even in UTF-16 (which is the encoding of a unicodestring), a single character may take up more than one code point, so this is not 100% safe yet either. If you want a guarantee to string[i] corresponding 1 single character, you a) have to normalize the unicode string to remove decomposed characters, and then b) convert it to an UTF-32 string. You can use this routine for the unicodestring to UTF-32 conversion: http://www.freepascal.org/docs-html/rtl/system/unicodestringtoucs4string.html (note that UCS4String is a dynamic array, not a string type) I don't know whether Lazarus contains platform-indepdendent wrappers for a). FPC itself at least doesn't at this time. 2) you will have to make sure that your Rects_low and LastCharacterDefined are defined in terms of UTF-16. Unless they are all plain ASCII characters (i.e., with an ordinal value=127), using a simple range is unlikely to work correctly. This is how Rect_low (=0) and LastCharacterDefined (byte) are declared. unit uFixedWidthFonts; {$MODE Delphi} interface uses graphics, ExtCtrls, SysUtils, Dialogs, SDL; const Rects_low = 0; Rects_high = 255; type PFixedFont = ^TFixedFont; TFixedFont = object private Image: TBitmap; // [ALVAROGP] Rects redefined as array of class TSDL_Rect { Rects: array[Rects_low..Rects_high] of PSDL_Rect; } Rects: array[Rects_low..Rects_high] of TSDL_Rect; public LastCharacterDefined: byte; TransparentColor, TextColor, BackgroundColor: Tcolor; // this is used only when UseTransparentBackground is false Char_width, Char_height: byte; // default is 8x8 ReverseVideo: Boolean; // default =false HorizontalGap: byte; // Horizontal Gap between characters in Pixels -- default =1 UseTransparentBackground: Boolean; constructor Initialize; procedure LoadFont(const Fontfile: string); procedure FreeUpAll; destructor Finalize; procedure WriteText2(x, y: integer; Txt: string; var PaintBox1: TPaintBox); end; var Font1: PFixedFont; A simpler alternative, with fairly high chances of data loss, is something like this: var mytxt: ansistring; begin mytxt:=utf8decode(txt); { now perform all operations on mytxt instead of on txt } ... end; This will first decode the UTF-8 encoded string to an UTF-16 encoded unicodestring, and then convert this unicodestring to a plain ansistring. Data loss can happen in case the string contains characters that cannot be represented using the ansi (~ default) code page of the system the program is running on. Such non-representable characters will be replaced by '?'. I could have used your above code as unknown characters appearing as '?' characters is acceptable. In summary, unless you are an expert at working with unicode, you should not work with such string at the character/code point level, and use higher level helpers instead to achieve what you want to do. You may want to ask for help about that on the Lazarus mailing list (subscription information at http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus), by describing what exactly it is you want to do rather than showing how you are currently doing it. I am not a unicode expert, but I am interested to learn new skills. Yes, I am a member of the Lazarus list. For some reason I got Lazarus and Free Pascal confused and perhaps wrongly assumed that this question was better suited to the FP list. Jonas___ Thank you. Peter / pew fpc-pascal maillist - fpc-pas...@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- ___ Lazarus
[Lazarus] [SOLVED] Re: SDL.pas Error while linking in Lazarus 0.9.28.2 and 0.9.29
Hi Henry, On 01/16/2011 02:50 AM, Henry Vermaak wrote: On 15 January 2011 15:38, Pew (piffle.the.cat) piffle.the@iinet.net.au wrote: Hi Dominique all, I have tried without success to get a project with only uses SDL to compile. /usr/bin/ld: cannot find -lSDL http://wiki.lazarus.freepascal.org/Lazarus_Faq#I_receive_an_error_during_the_linking_that_states_.2Fusr.2Fbin.2Fld_can.27t_find_-l.3Csome_lib.3E On my system (debian) there is a libsdl1.2-dev. It may be similar on ubuntu. Henry -- There are more files involved that just that one. http://pastebin.com/Sg2PgXY6 I think that it will work now. pew ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Frog game. OO-izing SDL. Replace record with class then Lazarus can't find .create or .free for class
Hi All, http://hotfile.com/dl/100225293/35136c1/frog_game.tar.gz.html I am modernising the SDL unit by replacing all of the records with classes. This should avoid warnings. basically all whatever = record x : integer; // blah blah blah end; becomes whatever = class public x : integer; // blah blah blah end; and then var whatever1 : whatever; begin // new(whatever1); // becomes whatever1 := whatever.create; ... uFixedWidthFonts.pas(98,21) Error: Unknown record field identifier CREATE uFixedWidthFonts.pas(177,17) Error: Operator is not overloaded uFixedWidthFonts.pas(182,16) Error: Unknown record field identifier FREE uFixedWidthFonts.pas(253) Fatal: There were 3 errors compiling module, stopping and Lazarus does not understand how to do a whatever1.whatever.create; nor a whatever1.free; Best Regards, pew -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] ERROR compiling Lazarus for first time on Windows 7 Ultimate OS. Fatal: Can't find unit system used by AllLCLUnits
On 01/25/2011 11:59 PM, Mattias Gaertner wrote: On Tue, 25 Jan 2011 23:00:22 +1100 Peter Williamspewilliams2...@live.com wrote: [...]On Sat, Jan 22, 2011 at 5:31 PM, Peter Eric Williams piffle.the@iinet.net.au wrote: Hi pascal list, Please excuse me asking such a basic question, but I'm new to this list. I require the basic instructions for quick start with subversion for all of the free pascal compiler using subversion. I am using Windows 7 Ultimate and I am new to Free Pascal and Lazarus. I have previously used Linux Ubuntu and Mint 10 with stable version of free Pascal and Lazarus. I am not wanting to use a pirate copy of Delphi XE and I am a supporter of free pascal and the GNU GPL 3 license. I have been reading the Development Tutorial (a.k.a Build FAQ) Copy and paste follows from the Dev. Tut. pdf file, section 1.3.3 (with my comments //). Please note the crap characters when I copy and pasted it. 1.3.3 Downloading source via SVN „To c™he™k out a— module use the follow line: svn co http://svn.freepascal.org/svn/module/trunk module # # Examples: # # FPC # svn co http://svn.freepascal.org/svn/fpc/trunk fpc # # fpcdocs # svn co http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs # # fpcprojects (has no branches, maybe you don't need /trunk at the end) # svn co http://svn.freepascal.org/svn/fpcprojects/trunk fpcprojects # # lazarus # svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus „ o ™he™k out — ˜r—n™hD repl—™e trunk in the —˜ove lines with the ˜r—n™hesG`˜r—n™h n—mebF iFgF to ™he™k out the ˜r—n™h (xes•P•RX // to check out a branch replace trunk in the above lines with branches/branch name E.g. To checkout the branches_2.4 5 \href{ftp://ftp.freepascal.org/pub/fpc/snapshot/v24/source/fpc.zip}{ftp://ftp.freepascal.org/pub/fpc/snapshot/v24/source/fpc.zip 6 \href{ftp://ftp.freepascal.org/pub/fpc/snapshot/v25/source/fpc.zip}{ftp://ftp.freepascal.org/pub/fpc/snapshot/v25/source/fpc.zip development series)} (2.2.x)} (2.5.x CHAPTER 1. BASE PRINCIPLES, NAMING, VERSIONS, REQUIREMENTS ETC IQ svn co http://svn.freepascal.org/svn/fpc/branches/fixes_2_4 fpc-2.4.x ƒpe™i(™ rele—ses —re t—gged with — t—g th—t is form—ted like ‚ivieƒi•P•R•H D —nd ™—n ˜e ™he™ked out like thisX svn co http://svn.freepascal.org/svn/fpc/tags/RELEASE_2_4_0 fpc-2.4.0 I had some problems when I tried install FPC and Lazarus on WinXP. So, after I made this tutorial: http://wiki.lazarus.freepascal.org/Installing_Lazarus#Compiling.2Finstalling_FPC_and_Lazarus_from_Sources_of_SVN_.28Win32.29 ...any installation on Windows I always use it. Marcos Douglas ___ fpc-pascal maillist - fpc-pas...@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal Fatal: Can't find unit system used by AllLCLUnits [...] How did you install fpc 2.5.1? Well? I followed the instructions here: http://wiki.lazarus.freepascal.org/Installing_Lazarus#Compiling.2Finstalling_FPC_and_Lazarus_from_Sources_of_SVN_.28Win32.29 ...any installation on Windows I always use it. Marcos Douglas Message from Free Pascal discussion list. On Sat, Jan 22, 2011 at 5:31 PM, Peter Eric Williams piffle.the@iinet.net.au wrote: Hi pascal list, Please excuse me asking such a basic question, but I'm new to this list. I require the basic instructions for quick start with subversion for all of the free pascal compiler using subversion. I am using Windows 7 Ultimate and I am new to Free Pascal and Lazarus. I have previously used Linux Ubuntu and Mint 10 with stable version of free Pascal and Lazarus. I am not wanting to use a pirate copy of Delphi XE and I am a supporter of free pascal and the GNU GPL 3 license. I have been reading the Development Tutorial (a.k.a Build FAQ) Copy and paste follows from the Dev. Tut. pdf file, section 1.3.3 (with my comments //). Please note the crap characters when I copy and pasted it. 1.3.3 Downloading source via SVN „To c™he™k out a— module use the follow line: svn co http://svn.freepascal.org/svn/module/trunk module # # Examples: # # FPC # svn co http://svn.freepascal.org/svn/fpc/trunk fpc # # fpcdocs # svn co http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs # # fpcprojects (has no branches, maybe you don't need /trunk at the end) # svn co http://svn.freepascal.org/svn/fpcprojects/trunk fpcprojects # # lazarus # svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus „ o ™he™k out — ˜r—n™hD repl—™e trunk in the —˜ove lines with the ˜r—n™hesG`˜r—n™h n—mebF iFgF to ™he™k out the ˜r—n™h (xes•P•RX // to check out a branch replace trunk in the above lines with branches/branch name E.g. To checkout the branches_2.4 5 \href{ftp://ftp.freepascal.org/pub/fpc/snapshot/v24/source/fpc.zip}{ftp://ftp.freepascal.org/pub/fpc/snapshot/v24/source/fpc.zip 6
[Lazarus] Commands with Linux and subversion to install Lazarus 0.9.30
Hi Lazarus list, $ mkdir lazarus_0.9.30 $ svn co http://svn.freepascal.org/svn/lazarus/branches/fixes_0_9_30/ lazarus_0.9.30 $ cd lazarus_0_9_30 $ mv lazarus lazarus.old $ make clean all $ ./lazarus works fine. I strongly suggest to the maintainer of fixes_0_9_30 to rename the lazarus folder to lazarus.old. This avoid the conflict with the lazarus binary file which is created with the make clean all command. Best Regards, pew -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Commands with Linux and subversion to install Lazarus 0.9.30
On 01/11/2011 05:08 AM, waldo kitty wrote: On 1/10/2011 12:57, Vincent Snijders wrote: 2011/1/10 Pew (piffle.the.cat)piffle.the@iinet.net.au: I strongly suggest to the maintainer of fixes_0_9_30 to rename the lazarus folder to lazarus.old. This avoid the conflict with the lazarus binary file which is created with the make clean all command. Why has the maintainer to do that? to prevent the apparent conflict that is there?? Exactly. Can't you do that yourself? if and when one figures out what the problems is, they probably could... I am still learning the svn commands How can the maintainer do that? it would seem that they would change it in the svn tree if i've read the given list of commands correctly... We need the svn command to rename the folder lazarus to lazarus.old -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Commands with Linux and subversion to install Lazarus 0.9.30
On 01/11/2011 05:13 AM, Pew (piffle.the.cat) wrote: On 01/11/2011 05:08 AM, waldo kitty wrote: On 1/10/2011 12:57, Vincent Snijders wrote: 2011/1/10 Pew (piffle.the.cat)piffle.the@iinet.net.au: I strongly suggest to the maintainer of fixes_0_9_30 to rename the lazarus folder to lazarus.old. This avoid the conflict with the lazarus binary file which is created with the make clean all command. Can't you do that yourself? if and when one figures out what the problems is, they probably could... Please read this page http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.move.html and work out what the command is to rename the folder lazarus to lazarus.old on http://svn.freepascal.org/svn/lazarus/branches/fixes_0_9_30/lazarus (folder) needs to be renamed to http://svn.freepascal.org/svn/lazarus/branches/fixes_0_9_30/lazarus.old I am still learning the svn commands pew -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Commands with Linux and subversion to install Lazarus 0.9.30
Hi Vincent, On 01/11/2011 05:40 AM, Vincent Snijders wrote: 2011/1/10 Pew (piffle.the.cat)piffle.the@iinet.net.au: Please read this page http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.move.html and work out what the command is to rename the folder lazarus to lazarus.old on http://svn.freepascal.org/svn/lazarus/branches/fixes_0_9_30/lazarus (folder) needs to be renamed to http://svn.freepascal.org/svn/lazarus/branches/fixes_0_9_30/lazarus.old Impossible, http://svn.freepascal.org/svn/lazarus/branches/fixes_0_9_30/lazarus gives: Not Found As an interim, please document these steps as a work around: $ mkdir lazarus_0.9.30 $ svn co http://svn.freepascal.org/svn/lazarus/branches/fixes_0_9_30/ lazarus_0.9.30 $ cd lazarus_0_9_30 $ mv -t lazarus lazarus.old $ make clean all $ ./lazarus works fine. The requested URL /svn/lazarus/branches/fixes_0_9_30/lazarus was not found on this server. Apache/2.2.8 (Ubuntu) DAV/2 SVN/1.6.5 PHP/5.2.4-2ubuntu5.12 with Suhosin-Patch Server at svn.freepascal.org Port 80 Please read the svn book, to get a better understand about what you as user can do and what can be done on the svn server. Thanks. To be quite honest I am now more interested in using Java and/or JavaScript for my cross-platform games development and I will pursue porting my existing Delphi and Lazarus games applications to Java/Javascript. Vincent -- Best Regards, pew ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] fpGUI + SDL versus Lazarus + SDL -- pros and cons
Hi Graeme and all, Subject edited. Cross posted to Lazarus and Free Pascal lists. On 01/09/2011 09:08 PM, Graeme Geldenhuys wrote: 2011/1/9 Zaher Dirkeyparm...@gmail.com: If you not use it, would you please make it as an option (new Platform). Yes, it will definitely be a new platform. fpGUI would then have eg: GDI, X11, SDL etc. as backends. Can fpGUI *currently* be used with (JEDI-)SDL? Also, what the sources of the latest SDL libraries and demos for Lazarus? I could only find (and download) JEDI-SDLv1.0.zip, which is for Delphi and someone else here (on the Lazarus list) offered to send me the latest version. Who is the administrator for the JEDI-SDL official releases? Are you doing your job, or voluntary role? :-) If you say Yes then why is the latest version of JEDI-SDL not currently available for download by the public? Is the latest Lazarus Free Pascal version of JEDI-SDL only available via the peer group of it's users? :-( If that is true then it is time that a new official version is published on Source Forge (currently at v1.0) for Delphi only. What is the difference between using fpGUI with SDL and Lazarus with SDL? Does the fpGUI + SDL create smaller binaries (on linux) versus Lazarus + SDL? Or are the other pros and cons? I have a Lazarus and SDL game application and I was not aware of the option of using fpGUI + SDL. Advantages and disadvantages, please? pew -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Compile time errors. Error: Duplicate identifier Fragments line 21 and AnsiStrings question.
Hi Lazarus list, I am updating some working code by rewriting some of the constant declarations. It is for a game called Awful Mint Things from Outer Space which is a free clone of Awful Green Things from Outer Space, and will be released under GNU GPL 3, around January or February. Note that I am having trouble reading my Pascal text books as I have misplaced my reading glasses :-( !!! I currently have 2 issues: 1) How do I define fragments_to_eggs_subrange which is an enumerated portion of green_types. 2) How do I define a constant array of strings // string_stunned_the_green_message, etc The constant array of string is needed for converting messages in my Lazarus application for cross language translation e.g. French, Spanish, Italian, Esperanto, etc. I intend to use http://www.langtolang.com for the translations. I think that I will modify my code to read an inifile then use TStringLists or similar and the LoadFromFile method. Will this work?!? I believe that I cannot use plain strings as these language use special symbols over the characters ?emluts? etc. How are these represented as strings or AnsiStrings? unit test1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs; type TForm1 = class(TForm) private { private declarations } public { public declarations } end; type green_types = ( Fragments, Babies, Adults, Eggs, Group_of_Green_things ); // line 21 fragments_to_eggs_subrange = (Fragments..Eggs) : green_types; // ^ //test1.pas(21,42) Error: Duplicate identifier Fragments //test1.pas(21,42) Hint: Identifier already defined in test1.pas at line 19 //test1.pas(21,42) Fatal: Syntax error, ) expected but .. foundunit test1.pas Hint: Start of reading config file /etc/fpc.cfg Hint: End of reading config file /etc/fpc.cfg Free Pascal Compiler version 2.4.0-2 [2010/03/06] for i386 Copyright (c) 1993-2009 by Florian Klaempfl Target OS: Linux for i386 Compiling testproject1.lpr Compiling test1.pas test1.pas(21,42) Error: Duplicate identifier Fragments test1.pas(21,42) Hint: Identifier already defined in test1.pas at line 19 test1.pas(21,42) Fatal: Syntax error, ) expected but .. foundunit test1.pas babies_to_eggs_subrange = (Babies..Eggs) : green_types; green_things_type = record present_count = array[ fragments_to_eggs_subrange ] of integer; stunned_count = array[ fragments_to_eggs_subrange ] of integer; new_count = array[ babies_to_eggs_subrange ] of integer; end; var green_things : array[ room_subrange ] of green_things_type; procedure do_kill_stun( lower, upper : byte; trying_to_stun : boolean; j : integer ); type array_of_green_types_strings = array[ green_types ] : string; string_stunned_the_green_message = array_of_green_types_strings; string_killed_the_green_message = array_of_green_types_strings; string_no_longer_here_the_green_message = array_of_green_types_strings; string_survived_message = array_of_green_types_strings; const string_stunned_the_green_message [ Fragments ] = ' stunned the Fragment'; string_stunned_the_green_message [ Babies] = ' stunned the Baby'; string_stunned_the_green_message [ Adults] = ' stunned the Adult'; string_stunned_the_green_message [ Eggs ] = ' stunned the Egg'; string_stunned_the_green_message [ Group_of_Green_Things ] = ' stunned the Group of Green Things'; [snip] var green, green_jj : green_types; k, count : byte; temp_green_count : array[ fragments_to_eggs_subrange ] of integer; begin roll := random_in_range( lower, upper ); if attacking_what = 'an Egg' then green_jj := Eggs else if attacking_what = 'a Baby' then green_jj := Babies else if attacking_what = 'a fragment' then green_jj := Fragments else if attacking_what = 'an Adult' then green_jj := Adults else { attacking a group } green_jj := Group_of_Green_things; end; info_form.SynMemo1.lines.add( 'The Egg''s constitution is: ' + inttostr( green_stats[ eggs ].constitution ) ); info_form.SynMemo1.lines.add( 'He rolled a ' + inttostr( roll ) ); temp_green_count[ green_jj ] := crew_data[ j ].green_data.present_count[ green_jj ]; case green_jj of Fragments..Eggs : begin if roll = green_stats[ green_jj ].constitution then begin if green_things[ attack_room_no ].present_count[ green_jj ] 0 then begin dec( green_things[ attack_room_no ].present_count[ green_jj ] ); if trying_to_stun then begin inc( green_things[
Re: [Lazarus] Compile time errors. Error: Duplicate identifier Fragments line 21 and AnsiStrings question. [SOLVED]
Hi Howard, This game was inspired by the 1968 movie The Green Slime http://www.imdb.com/title/tt0064393/ On 01/08/2011 11:09 PM, Howard Page-Clark wrote: On 08/1/11 10:13, Pew (piffle.the.cat) wrote: Hi Lazarus list, ... I currently have 2 issues: 1) How do I define fragments_to_eggs_subrange which is an enumerated portion of green_types. 2) How do I define a constant array of strings // string_stunned_the_green_message, etc Thank you. My pascal is a bit rusty and I have an excellent text book, however, I need to buy some new reading glasses. I will do that on Monday. :-) You want the following: type green_types = ( Fragments, Babies, Adults, Eggs, Group_of_Green_things ); fragments_to_eggs_subrange = Fragments..Eggs; const GreenTypeStrings : array[green_types] of string = (' stunned the Fragment', ' stunned the Baby', ' stunned the Adult', ' stunned the Egg', ' stunned the Group of Green Things'); // not compiled yet My next step is to change the const definition to variables so that I can define: type languages = ( English, Italian, German, Spanish, Esperanto, Simplified_Chinese, Japanese ); // I probably need to define the font name for each language also // does anyone know the standard linux fonts for these languages??? AnsiString_noun_of_green_message_2D_array = array[languages,green_types] of AnsiString; // etc etc etc article_language_array = array[languages] of AnsiString; definitive_article_array = array[languages] of AnsiString; var AnsiString_noun_of_green_message : array[green_types] of AnsiString; { (' a Fragment', ' a Baby', ' an Adult', ' an Egg', ' The Group of Green Things'); } type language_array_of_AnsiString = array[ languages ] of AnsiString; AnsiString_constitution_is : language_array_of_AnsiString; // = ' constitution is: ' AnsiString_He_rolled_a : language_array_of_AnsiString; // = 'He rolled a ' AnsiString_stunned_the_green_message: language_array_of_AnsiString; // = ' stunned ' AnsiString_killed_the_green_message: language_array_of_AnsiString; // = ' killed' AnsiString_There_is_no_longer: language_array_of_AnsiString; // = 'There is no longer' AnsiString_here_to_attack: language_array_of_AnsiString; // = ' here to attack.' AnsiString_survived_the_attack: language_array_of_AnsiString; // = ' survived the attack.') var AnsiString_There_is_no_longer : array[ languages ] of AnsiString; AnsiString_noun_of_green_things :array[ languages, green_jj ]of AnsiString; AnsiString_here_to_attack :array[ languages ]of AnsiString; // etc language : languages; begin { Ask user for language preference Open ini file and read file containing Ansi constants close ini file read and assign AnsiStrings from text file to variables close text file } // code fragment info_form.SynMemo1.lines.add( AnsiString_There_is_no_longer[ language ] + AnsiString_noun_of_green_things[ language, green_jj ]+ AnsiString_here_to_attack[ language ] ); // There is no longer a xxx here to attack. In the language of the user. end; var green, green_jj : green_types; k, count : byte; temp_green_count : array[ fragments_to_eggs_subrange ] of integer; begin roll := random_in_range( lower, upper ); if attacking_what = // an Egg article[language, 2]+' '+AnsiString_noun_of_green_message[Egg]then green_jj := Eggs else if attacking_what = // a Baby article[language,1]+' '+AnsiString_noun_of_green_message[Babies]then green_jj := Babies else if attacking_what = // a Fragment article[language,1]+' '+AnsiString_noun_of_green_message[Fragments]then green_jj := Fragments else if attacking_what = // an Adult article[language,2]+' '+AnsiString_noun_of_green_message[Adults]then green_jj := Adults else { a group of Green Things } green_jj := Group_of_Green_things; end; info_form.SynMemo1.lines.add( definitive_article + //green_types = ( Fragments, Babies, Adults, Eggs, Group_of_Green_things ); // e.g. The Egg's constitution is xxx // etc AnsiString_noun_of_green_message[ language, green_jj ] + ''' + AnsiString_constitution_is[ language ] + inttostr( green_stats[ eggs ].constitution ) ); info_form.SynMemo1.lines.add( AnsiString_He_rolled_ a + inttostr( roll ) ); temp_green_count[ green_jj ] := crew_data[ j ].green_data.present_count[ green_jj ]; if roll = green_stats[ green_jj ].constitution then begin if green_things[ attack_room_no ].present_count[ green_jj ] 0 then begin dec( green_things[ attack_room_no ].present_count[ green_jj ] ); if trying_to_stun then begin inc( green_things[ attack_room_no ].stunned_count[ green_jj ] ); info_form.SynMemo1.lines.add( name + AnsiString_stunned_the_green_message[ language ]+ AnsiString_noun_of_green_things[ language
[Lazarus] e: Compile time errors. Error: Duplicate identifier Fragments line 21 and AnsiStrings question. [SOLVED]
Hi Howard, On 01/08/2011 11:09 PM, Howard Page-Clark wrote: On 08/1/11 10:13, Pew (piffle.the.cat) wrote: Hi Lazarus list, ... I currently have 2 issues: 1) How do I define fragments_to_eggs_subrange which is an enumerated portion of green_types. 2) How do I define a constant array of strings // string_stunned_the_green_message, etc Thank you. My pascal is a bit rusty and I have an excellent text book, however, I need to buy some new reading glasses. I will do that on Monday. :-) You want the following: type green_types = ( Fragments, Babies, Adults, Eggs, Group_of_Green_things ); fragments_to_eggs_subrange = Fragments..Eggs; const GreenTypeStrings : array[green_types] of string = (' stunned the Fragment', ' stunned the Baby', ' stunned the Adult', ' stunned the Egg', ' stunned the Group of Green Things'); // not compiled yet const article : array[1..2] of AnsiString = 'a', 'an'; definitive_article = 'The '; AnsiString_noun_of_green_message : array[green_types] of AnsiString = (' Fragment', ' Baby', ' Adult', ' Egg', ' Group of Green Things'); AnsiString_constitution_is = ' constitution is: '; AnsiString_He_rolled_a = 'He rolled a '; AnsiString_stunned_the_green_message = ' stunned '; AnsiString_killed_the_green_message = ' killed'; AnsiString_There_is_no_longer = 'There is no longer'; AnsiString_here_to_attack = ' here to attack.'; AnsiString_survived_the_attack = ' survived the attack.'); My next step is to change the const definition to variables so that I can define: type languages = ( English, Italian, German, Spanish, Esperanto, Simplified_Chinese, Japanese ); // I probably need to define the font name for each language also // does anyone know the standard linux fonts for these languages??? article_language_array = array[languages] of AnsiString; definitive_article_array = array[languages] of AnsiString; AnsiString_noun_of_green_message_2D_array = array[languages,green_types] of AnsiString; // etc etc etc var article_language : article_language_array; definitive_article : definitive_article_array; AnsiString_There_is_no_longer : array[ languages ] of AnsiString; AnsiString_noun_of_green_things :array[ languages, green_jj ]of AnsiString; AnsiString_here_to_attack :array[ languages ]of AnsiString; language : languages; begin { Ask user for language preference Open ini file and read file containing Ansi constants close ini file read and assign AnsiStrings from text file to variables close text file } info_form.SynMemo1.lines.add( AnsiString_There_is_no_longer[ language ] + AnsiString_noun_of_green_things[ language, green_jj ]+ AnsiString_here_to_attack[ language ] ); end; var green, green_jj : green_types; k, count : byte; temp_green_count : array[ fragments_to_eggs_subrange ] of integer; begin roll := random_in_range( lower, upper ); if attacking_what = // an Egg article[language, 2]+' '+AnsiString_noun_of_green_message[Egg]then green_jj := Eggs else if attacking_what = // a Baby article[language,1]+' '+AnsiString_noun_of_green_message[Babies]then green_jj := Babies else if attacking_what = // a Fragment article[language,1]+' '+AnsiString_noun_of_green_message[Fragments]then green_jj := Fragments else if attacking_what = // an Adult article[language,2]+' '+AnsiString_noun_of_green_message[Adults]then green_jj := Adults else { a group of Green Things } green_jj := Group_of_Green_things; end; info_form.SynMemo1.lines.add( definitive_article + //green_types = ( Fragments, Babies, Adults, Eggs, Group_of_Green_things ); // e.g. The Egg's constitution is xxx // etc AnsiString_noun_of_green_message[ language, green_jj ] + ''' + AnsiString_constitution_is[ language ] + inttostr( green_stats[ eggs ].constitution ) ); info_form.SynMemo1.lines.add( AnsiString_He_rolled_ a + inttostr( roll ) ); temp_green_count[ green_jj ] := crew_data[ j ].green_data.present_count[ green_jj ]; if roll = green_stats[ green_jj ].constitution then begin if green_things[ attack_room_no ].present_count[ green_jj ] 0 then begin dec( green_things[ attack_room_no ].present_count[ green_jj ] ); if trying_to_stun then begin inc( green_things[ attack_room_no ].stunned_count[ green_jj ] ); info_form.SynMemo1.lines.add( name + AnsiString_stunned_the_green_message[ language ]+ AnsiString_noun_of_green_things[ language, green_jj ]); end else info_form.SynMemo1.lines.add( name + AnsiString_killed_the_green_message[ language ]+ AnsiString_noun_of_green_things[ language, green_jj ]); end else info_form.SynMemo1.lines.add( AnsiString_There_is_no_longer[ language ] + AnsiString_noun_of_green_things[ language
Re: [Lazarus] invisible break points??
Hi Martin, On 01/08/2011 11:04 AM, Martin wrote: On 07/01/2011 22:59, David Emerson wrote: I'm attaching some debug output. One of the logs was an execution with no breakpoints (view debug info breakpoints list is empty; also the lpi file has no breakpoints) and in the other execution I created one breakpoint. In the execution with no breakpoints, everything went smoothly. In the execution with the one breakpoint, the program stopped at debug log line 186, *stopped,reason=breakpoint-hit,bkptno=38, [...] (gdb) let's actually try helping the OP, Martin. Martin, please post the procedure up to the point where the code stops. And under the list where it stops paste the error message from the View / Messages window and some ^^^ to point to the code. That will help. Also, try to set a breakpoint one line BEFORE where you have the breakpoint set, as I believe that this is most likely the line where you code is crashing. The press F7 to step into the code and see what is going on. That way you will be able to watch what is really going on. Good luck and happy debugging. All of this talk about how the debugger works is not helping Martin, who only has one breakpoint set. Best Regards, pew, However, when I say the program stopped, lazarus did not behave as if it had encountered a breakpoint. The lazarus main and source windows did not raise; in the source editor, the line with the breakpoint is marked with a red highlight and checkmark, not with a blue highlight and arrow. Pressing F9 (while focused on the source window) has no effect whatsoever. The call stack window is empty, and the gdb debug output window does not show any stack info, either. Hm, I guess part of the problem is that console output of the application does not work well with gdb. It seems to mix with the gdb output From your log: = Databas*stopped,reason=breakpoint-hit,bkptno=38,thread-id=1,frame={addr=0x08073656,func=T_COMMAND_WINDOW__DO_MY_THING_BUTTON_PRESS,args=[{name=SENDER,value=0xb76998e0},{name=this,value=0xb7861f10}],file=ab_fpgui_types_unit.inc,fullname=/ab/Pascal/ab_fpgui_types_unit.inc,line=230} (gdb) the msgs from gdb goes on the same line, as the app's output. There is nothing the IDE can do, it has no chance of identifying the gdb output, or knowing there was a breakpoint... [snip] In my opinion, the program crashes then hits the breakpoint, so Martin needs to set the breakpoint a single line of code earlier and press F7. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] fpGUI
Hi Graeme On 01/06/2011 09:12 PM, Graeme Geldenhuys wrote: Here is a short animated gif showing form designing with fpGUI's UI Designer. 1 minute screencast, 1.1MB download. http://opensoft.homeip.net:8080/~graemeg/editform.gif Other than the obvious use of free pascal (fp ide, I think) what software did you use to capture the screen images and save them as an animated gif image? Was there any extra work for you to make it a self repeating/looping animated gif ? Regards, - Graeme - Pew :-) -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PNG vs. JPG
On 01/04/2011 12:46 AM, Jürgen Hestermann wrote: Bo Berglund schrieb: PNG is non-loss and also compresses the data much better (for a typical screenshot) so the resulting file is smaller too... Why should a loss-less compression compress better than a a lossy compression? In general this is not true, just the opposite. But you are right that for screenshots PNG is much better because it was optimized for computer generated pictures (like screenshots). JPG was made for photos and reduces their size dramatically because it takes into account human picture recognition. If you have photos (made by a camera) you will always get the best results with JPG. The problem with jpg is when people start to edit then re-save them. Have a look on google images for joke images where someone has added a border and some text to the image. Often times you'll see an bit of fussy-error area at some point. This is the lossy-ness being introduced by opening then re-saving, opening the new image and re-saving again 2-3 times or more. I am not sure whether browsers like Firefox also have lossy-ness when you find an image and right-click then do a save image as... I think so, but maybe not, as it probably really only copies the image from the browser's cache to the new location, hence not really saving but actually copying. I always prefer to use png image as masters for editing then output final image as jpg or png. As this is a duplication problem and also for the re-saving errors, I tend to only keep png's. pew -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus