* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
Databases / Re: Property NullDisplayText
« Last post by rvk on Today at 01:13:17 pm »
is there something equivalent to a .nulldisplaytext property, displayable in a database aware control to indicate that its value is not set in the resultset, like "n/a" instead of "".
For TEdit there is TEdit.TextHint which shows the text in grey when it is empty.

TDBEdit also has the TextHint but it isn't published. So I'm not sure it works for NULL.
You can try setting it in code.

2
General / Re: TFPExpressionParser and hex constants....
« Last post by wp on Today at 01:12:36 pm »
Normally I would have said: Do what ASerge says and add '$' to the set "Digits' in fpexprpars (immediately after "implementation").

But the parser still fails. The problem is in the line "val(FToken,X,I)" of TFPExpressionScanner.IsNumber, where FToken is the number string with the $, e.g. '$10'.

If I call "val('$10', X, I)" by itself it is converting the hex number without an issue, but inside fpexprpars it fails. What's going on here?

See attached project (it contains already a patched recent fpexprpars).
3
General / Re: Thread Safety?
« Last post by Thaddy on Today at 01:07:05 pm »
@ASerge
Quote
In the first case, can be, but it is almost impossible that the thread ends between two assignment operations.
That's a trap and you just fell into it: branch prediction/out of order executiion.
Use an atomic operation for the assignments and you are safe.. And that is actually quite easy using the InterlockedExchange(Ptr) family.

Basically the same lack of theory that causes you to use instead of ignore timing.

Rest of your code is quite neat.
4
General / Re: TFPExpressionParser and hex constants....
« Last post by ASerge on Today at 01:03:58 pm »
I'm trying to use TFPExpressionParser to evaluate expressions that use hexidecimal constants prefixed by $ but this does not seem to be working:
...
Does anyone have any idea how to make this work?
Copy fpexprpars.pp into your project. Rewrite TFPExpressionScanner.DoNumber so that it understands '$', and also if you want '&' and '%'.
5
Databases / Re: Property NullDisplayText
« Last post by marcov on Today at 12:56:05 pm »
You can hook the event that gets the displaytext, and do whatever transformation you want.

The classic reason to do that is for memo fields that are typically not shown in grids. e.g.

Code: Pascal  [Select]
  1. procedure TSqlCreateFrm.defaultgettext(Sender: TField; var Textit: string;
  2.   DisplayText: Boolean);
  3. begin
  4.     if DisplayText then
  5.      Textit := Copy(sender.AsString, 1, 50) // in case for display text, only show part
  6.   else
  7.      Textit:=sender.AsString;
  8. end;

In the designer or in code set thegrid.ongettext to defaultgettext;
6
General / SpkToolbar tab settings
« Last post by scons on Today at 12:50:10 pm »
Hi,


In SpkToolbar settings, for the pane and buttons you can choose to set the appearance rectangular, but not for the tabs.
If you have a pagecontrol just beneath it, it would look better if the appearance matches.

Are there some settings available to influence the appearance of the tabs (edges and distance between tabs for example) ?

Thanks

7
General / Re: Thread Safety?
« Last post by ASerge on Today at 12:43:12 pm »
@ASerge, if you choose to set FThread.FreeOnTerminate := True then consider FThread = nil when you start the thread.

In the case of your project the thread was already started. So this code could possibly (while not probable) fail:
Code: Pascal  [Select]
  1.   FThread.FreeOnTerminate := True;
  2.   FThread.OnTerminate := @ThreadTerminated;  //<---- May fail

Worse in the form destruction event:
Code: Pascal  [Select]
  1. procedure TForm1.FormDestroy(Sender: TObject);
  2. begin
  3.   if Assigned(FThread) then
  4.     FThread.OnTerminate := nil;  //<--- May fail
  5.   FThread.Free;  //<--- May fail
  6. end;

There is no guaranty that before assigning nil to OnTerminate that the thread had not destroyed itself (due to FreeOnTerminate = True)
In the first case, can be, but it is almost impossible that the thread ends between two assignment operations.
In the second case, everything is correct, because the thread does not freed until it calls OnTermnate in the main thread, but the main thread is busy doing these operations
8
Mac OS X / Re: getprocaddress
« Last post by rvk on Today at 12:27:10 pm »
I see much more problems with that code.
Where is the end for the begin/end block when Handle1 <> nil.
When I try to compile this... where (and what) is TLoadLibrary?
TLibHandle is a DWord (for me) so you can't check that against nil (which is a pointer). Check it against nilhandle.
Is "functioname" the real functioname? (note absence of n)

Is this better?
Code: Pascal  [Select]
  1. var
  2.   Handle1: TLibHandle;
  3.   ptr1: Pointer;
  4. begin
  5.   Handle1 := LoadLibrary('libTest.dylib');
  6.   if Handle1 <> nilhandle then
  7.   begin
  8.     ptr1 := GetProcAddress(Handle1, 'functioname');
  9.     if ptr1 <> nil then
  10.       writeln('Function address found');
  11.   end
  12.   else
  13.   begin
  14.     writeln('Failed ...');
  15.   end;
  16. end;


PLEASE DON'T POST JUST TYPED TEXT. Use real code you have in your project !!
One typo is easily made and we can't see your real code.
(and use the #-code button to mark code)
9
General / TFPExpressionParser and hex constants....
« Last post by Prime on Today at 12:25:29 pm »
Hi All,

I'm trying to use TFPExpressionParser to evaluate expressions that use hexidecimal constants prefixed by $ but this does not seem to be working :

Code condensed to remove other stuff not related to TFPExpressionParser

Code: Pascal  [Select]
  1. VAR
  2.     FParser     : TFPExpressionParser;
  3.  
  4. BEGIN;
  5.   FParser := TFPExpressionParser.Create(nil);
  6.   TRY
  7.      // TESTVAR has been added with FParser.Identifiers.AddIntegerVariable
  8.      FParser.Expression:='TESTVAR + $20';  // << throws an exception.
  9.  
  10.   FINALLY
  11.     FParser.Free;
  12.   END;
  13. END;
  14.  

The exception I get is "unknown character '$' at position x".

Does anyone have any idea how to make this work?

Cheers.

Phill.

10
Mac OS X / Re: getprocaddress
« Last post by RednosePete on Today at 12:20:23 pm »
Why you use a PChar cast  for LoadLibary and GetProcAdress?

Both functions want a normal String.

Ok,

thanks. I removed PChar and the same result; ppcx64  produces app that works, Lazarus (via lazbuild) not.
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