* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
Graphics / Re: Copying images from a Lazarus application
« Last post by hakelm on Today at 06:35:39 pm »
I always thought of bitmaps as rows and columns of pixels an pixel/m etc. was something for WYSIWYG applications and the printer.
But you always learn something.
H
2
General / Re: How to build pas2js
« Last post by molly on Today at 06:09:29 pm »
Thanks, but what is the "trunk checkout"?
Trunk is located here. for checkout, see wikipedia version control common vocabulary.

In short using version control tool to 'download' the most up to date sources from trunk (version 3.1.1 atm)

Quote
Here's what comes up when I do "locate pas2js" on my system:
Those are not up to date sources from trunk, rather those from FPC 3.0.4 release.

See also here in FPC/Lazarus wiki.
3
General / Re: How to build pas2js
« Last post by segfault on Today at 05:38:17 pm »
You need to use make clean all at the top level directory of the trunk checkout plus a make install (probably as root). Anything else requires experience to do.

Thanks, but what is the "trunk checkout"? Here's what comes up when I do "locate pas2js" on my system:

/usr/share/fpcsrc/3.0.4/packages/pastojs/src/fppas2js.pp
/usr/share/fpcsrc/3.0.4/packages/pastojs/tests/testpas2js.lpi
/usr/share/fpcsrc/3.0.4/packages/pastojs/tests/testpas2js.pp
/usr/share/fpcsrc/3.0.4/utils/pas2js
/usr/share/fpcsrc/3.0.4/utils/pas2js/Makefile
/usr/share/fpcsrc/3.0.4/utils/pas2js/Makefile.fpc
/usr/share/fpcsrc/3.0.4/utils/pas2js/dist
/usr/share/fpcsrc/3.0.4/utils/pas2js/fpmake
/usr/share/fpcsrc/3.0.4/utils/pas2js/fpmake.o
/usr/share/fpcsrc/3.0.4/utils/pas2js/fpmake.pp
/usr/share/fpcsrc/3.0.4/utils/pas2js/pas2js.lpi
/usr/share/fpcsrc/3.0.4/utils/pas2js/pas2js.pp
/usr/share/fpcsrc/3.0.4/utils/pas2js/samples
/usr/share/fpcsrc/3.0.4/utils/pas2js/dist/rtl.js
/usr/share/fpcsrc/3.0.4/utils/pas2js/samples/arraydemo.pp
/usr/share/fpcsrc/3.0.4/utils/pas2js/samples/fordemo.pp
/usr/share/fpcsrc/3.0.4/utils/pas2js/samples/fordowndemo.pp
/usr/share/fpcsrc/3.0.4/utils/pas2js/samples/hello.pas
/usr/share/fpcsrc/3.0.4/utils/pas2js/samples/ifdemo.pp
/usr/share/fpcsrc/3.0.4/utils/pas2js/samples/repeatdemo.pp
/usr/share/fpcsrc/3.0.4/utils/pas2js/samples/whiledemo.pp

So which directory do I "make clean install" from?
4
General / Re: Need some Help for RightToLeft TWinControls
« Last post by wp on Today at 05:37:28 pm »
The doublebuffering machinery for Windows has been reworked a few days ago. Please test Lazarus trunk.
5
General / Re: Error in conditionals - Lazarus 1.8.0 Win32
« Last post by Bart on Today at 05:03:43 pm »
OK, totally off-topic, but this really hurts my eyes.

Code: Pascal  [Select]
  1. Function BaseXTable(xNum: Variant; nBase: Extended; lSwStr: Boolean): Variant;  
  2. ...
  3. Begin
  4. ...
  5. If (IsRange(nBase, 2, 252) <> False) Then Begin
  6. If (lSwStr <> True) Then Begin
  7. ...
  8. End;
  9.  

OMG!
I don't even know where to begin here.

IsRange() returns a boolean, why compare it to another boolean, and why "<>False"?
The "<>False" suggests that there are more options than True/False.
Essentially "<>False" is "not False", which of course is "True".

So you want to know if IsRange() returns True.
The proper way to do so is simply:
Code: Pascal  [Select]
  1. If IsRange(nBase, 2, 252) Then Begin

And mutatis mutandis (google that):
Code: Pascal  [Select]
  1. If  not lSwStr Then Begin

[rant]
And no, comparing a Boolean to True or False does NOT make your code better readable.
Also if you do that, you are rather inconsistent, since the expression (ABoolean = False) results in yet another boolean expression, and you seem to have decided that you need to compare a Boolean expression agains either True of False, so to be consistent you should do if ((ABoolean=False)=True), but even this then is a Boolean expression, which, by your standards has to be compared against True or False, so it needs to be extended to (((ABoolean=False)=True)=True), which unfortunately in itself is a Boolean expression, which in all fairness needs to be compared against True or False, so we get ((((ABoolean=False)=True)=True)=True), which of course still is not enough, so
Code: Pascal  [Select]
  1. (((((ABoolean=False)=True)=True)=True)=True)
etc. etc.
And to be absolutely sure that the compiler knows about True and False, you need to start each Boolean expression by
Code: Pascal  [Select]
  1.   if not (True xor False) then FatalError;
Just because, you know, the compiler may be off a bit, or you run fpc on a quantum computer, where a Boolean can be True and False at the same time, or even not True and not False (google Schrödingers cat), and this will screw up the logic of your program, so if you run the program on such a system you must abort it (and preferrably display a message stating that programs compiled with freepascal cannot run on quantum computers, and that the compiler sucks and that this has nothing to do with possible bugs in your code, because, you know, you have decades of experience in designing compilers that run flawlessly, because you are a genius, and you really know the meaning of Boolean expressions and why you always must compare them against absolute True and/or False and ....
[/rant]

Sorry, I got a little bit carried away.

The main point of course is that I sincerely wish you have fun programming, wether this is in Pascal or some other language.
And that you don't mind that some grumpy old man, that sometimes wishes programming was as simple as in the days of Turbo Pascal 3.0, writes grumpy comments in threads you started.

If you feel up to it, please rewrite your Boolean expressions to be a litle more in line with the language you write them in.

Bart
6
General / Re: Error in conditionals - Lazarus 1.8.0 Win32
« Last post by ASerge on Today at 04:37:49 pm »
Code: Pascal  [Select]
  1. //...
  2. If (IsRange(nBase, 2, 252) <> False) Then Begin
  3. If (lSwStr <> True) Then Begin
  4.  If (IsRange(xNum, 0, 9) <> False) Then xTmp := Char(xNum + 48) Else
  5. //...
  6.  
For me, it's easier:
Code: Pascal  [Select]
  1. //...
  2.   if InRange(nBase, 2, 252) then begin
  3.   if not lSwStr then begin
  4.   if InRange(xNum, 0, 9) then xTmp := Char(xNum + 48) else
  5. //...
  6.  
And stop Visual Basic style. Read Coding Guidelines for Lazarus.
My example of your code, if I understand it correctly:
Code: Pascal  [Select]
  1. program Project1;
  2. {$APPTYPE CONSOLE}
  3. {$mode objfpc}
  4.  
  5. uses Math, SysUtils;
  6.  
  7. {$WARN 3177 OFF: Some fields coming after "$1" were not initialized}
  8. const
  9.   CMagicTable: array [1..12] of record
  10.     UpTo: Integer;
  11.     case Add: Integer of
  12.       0: (Direct: Integer);
  13.   end = ( // ordered by UpTo - it is important
  14.    (UpTo:9; Add:48),
  15.    (UpTo:35; Add:55),
  16.    (UpTo:61; Add:61),
  17.    (UpTo:62; Add:0; Direct: 43),
  18.    (UpTo:63; Add:0; Direct: 47),
  19.    (UpTo:196; Add:59),
  20.    (UpTo:202; Add:-106),
  21.    (UpTo:209; Add:-145),
  22.    (UpTo:210; Add:0; Direct: 44),
  23.    (UpTo:220; Add:-178),
  24.    (UpTo:238; Add:-207),
  25.    (UpTo:251; Add:-238));
  26.  
  27. function BaseXTable(xNum: Integer; nBase: Integer): string; overload;
  28. var
  29.   Code: Integer;
  30.   Index: Integer;
  31. begin
  32.   if InRange(nBase, 2, 252) then
  33.   begin
  34.     Code := xNum;
  35.     for Index := Low(CMagicTable) to High(CMagicTable) do
  36.     begin
  37.       if Code <= CMagicTable[Index].UpTo then
  38.       begin
  39.         if CMagicTable[Index].Add <> 0 then
  40.           Inc(Code, CMagicTable[Index].Add)
  41.         else
  42.           Code := CMagicTable[Index].Direct;
  43.         Exit(Chr(Code));
  44.       end;
  45.     end;
  46.   end;
  47.   Result := '*** Error ***';
  48. end;
  49.  
  50. function BaseXTable(const xNum: string; nBase: Integer): string; overload;
  51. var
  52.   S: string;
  53.   Code: Integer;
  54.   Min, Max, Index: Integer;
  55.   Fit: Boolean;
  56. begin
  57.   if InRange(nBase, 2, 252) then
  58.   begin
  59.     S := Trim(xNum);
  60.     if nBase < 36 then
  61.       Code := Ord(UpCase(S[1]))
  62.     else
  63.       Code := Ord(S[1]);
  64.     for Index := Low(CMagicTable) to High(CMagicTable) do
  65.     begin
  66.       if CMagicTable[Index].Add = 0 then
  67.       begin
  68.         if Code = CMagicTable[Index].Direct then
  69.         begin
  70.           Code := CMagicTable[Index].UpTo;
  71.           Break;
  72.         end;
  73.       end
  74.       else
  75.       begin
  76.         Min := CMagicTable[Index].Add;
  77.         Max := CMagicTable[Index].Add + CMagicTable[Index].UpTo;
  78.         if Min <= Max then
  79.           Fit := InRange(Code, Min, Max)
  80.         else
  81.           Fit := InRange(Code, Max, Min);
  82.         if Fit then
  83.         begin
  84.           Dec(Code, CMagicTable[Index].Add);
  85.           Break;
  86.         end;
  87.       end;
  88.     end;
  89.     if Code < nBase then
  90.       Exit(Chr(Code));
  91.   end;
  92.   Result := '*** Error ***';
  93. end;
  94.  
  95. begin
  96.   Writeln(BaseXTable(27, 36));
  97.   Writeln(BaseXTable(BaseXTable(27, 36), 36));
  98.   Readln;
  99. end.

7
General / Re: Error in conditionals - Lazarus 1.8.0 Win32
« Last post by rvk on Today at 03:52:21 pm »
I do see your problem. It has to do with using variants in the char() function.

To illustrate:
Code: Pascal  [Select]
  1. var
  2.   xTmp ,xNum: variant;
  3. begin
  4.   xNum := 27;
  5.   xTmp := char(xNum + 55);
  6.   Showmessage(xTmp + ' is different from ' + char(27 + 55));
  7. end;
This will show "8 is different from R".

The problem is char(xNum + 55) with xNum being variant 27.

If you change it to this it will work fine:
Code: Pascal  [Select]
  1. xTmp := char(Integer(xNum) + 55);
(You'll need to do that with the other lines too. Mixing variants with numbers seems dangerous. It would be better to just convert xNum it to integer and use that.)

I'll leave it to the experts to explain why xNum is not seen as Integer when doing XNum+55 inside the Char() function (and to see if that's not a bug).
8
Did you instruct people about OPM without using it yourself?
obviously not, I addressed a problem with a package installation not the reason the problem was created. I simple posted an assumption on why it happened, if I'm wrong then I'm wrong, but I do not see any other theories so far.
9
Hello.
I have a Motorola/Symbol MC9090G that has an RFID scanner. I'd like to know how to scan RFID tags using Lazarus Pascal. I'm  already scanning barcode labels (using SCNAPI32.DLL). How do I select the scanner between barcode and RFID? Is there other unit available for doing that?
Thanks.
Ricardo Ramos
Brazil
10
General / Re: Error in conditionals - Lazarus 1.8.0 Win32
« Last post by Handoko on Today at 03:19:01 pm »
I copied and tested your code using step over (F8), the flow exit the multiple ifs after:

Code: Pascal  [Select]
  1.  xTmp := Char(xNum + 55);

Which means it's working correctly on my test.

I ever have experience, my code didn't work as what it should be but I fixed it by deleting the binary and lib folder and recompile again the source code. Maybe it can fix your issue too.
Pages: [1] 2 3 ... 10

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus