Recent Posts

Pages: [1] 2 3 ... 10
1
Pascal sets are ordinals

RTTI settles it: a set gets its own kind, tkSet, sitting next to tkDynArray among the structural types - not next to tkEnumeration among the ordinal ones. And the ordinal-only builtins reject it outright, while accepting the enum it was built from.

Code: Pascal  [Select][+][-]
  1. program ordinals;
  2.  
  3. {$mode unleashed}
  4.  
  5. uses TypInfo;
  6.  
  7. function TypeNameOf(ti: PTypeInfo): string;
  8. begin
  9.   result := 'name: '+(if ti^.Name<>'' then ti^.Name else '-')+ ', kind: '+GetEnumName(TypeInfo(TTypeKind), Ord(ti^.Kind));
  10. end;
  11.  
  12. type
  13.   TDay  = (mon, tue, wed);
  14.   TDays = set of TDay;
  15.   TArrI = array of Integer;
  16.  
  17. var
  18.   d: TDay;
  19.   x: TDays;
  20.  
  21. begin
  22.   writeln('TDay  = ', TypeNameOf(TypeInfo(TDay)));   // tkEnumeration  <- ordinal
  23.   writeln('TDays = ', TypeNameOf(TypeInfo(TDays)));  // tkSet          <- structural
  24.   writeln('TArrI = ', TypeNameOf(TypeInfo(TArrI)));  // tkDynArray     <- structural
  25.   writeln;
  26.  
  27.   d := mon;
  28.   writeln(Ord(d));      // ok - TDay is ordinal
  29.   writeln(Succ(d));     // ok
  30.   writeln(Low(TDay));   // ok - returns TDay
  31.  
  32.    //writeln(Ord(x));   // Error: Ordinal expression expected
  33.    //x := Succ(x);      // Error: Ordinal expression expected
  34.    //x := Low(TDays);   // Error: Incompatible types: got "TDay" expected "TDays"
  35. end.
2
Pascal and AI / LLAMA Control Center
« Last post by Inyong on Today at 04:33:03 am »
Hi everyone,

I’d like to introduce Llama Control Center, a fast, native desktop GUI and management suite for llama.cpp, built entirely with Free Pascal and Lazarus LCL.

✨ Key Features:
Server Control & Telemetry: Full lifecycle management (Start/Stop/Restart) with real-time PID, uptime, and state tracking.

Hardware Monitoring: Live telemetry for CPU, system RAM, and GPU VRAM usage.

GGUF Model Hub: Browse and inspect local models and metadata easily.

AI Playground: Interactive chat workspace with streaming support.

Benchmark Suite: Integrated llama-bench testing for Prompt Processing (PP) and Text Generation (TG) speeds.

Smart Path Resolver & Tray: Automatic binary detection on startup and system tray integration.

It provides a lightweight, native alternative to heavy web-based wrappers. Feedback and suggestions from the Lazarus community are very welcome!

Happy coding!


https://github.com/CodeInPas/LlamaControlCenter

3
I had wanted to suggest this feature, now it is here. But the application name is misleading now. An "LRS Editor" is expected to allow editing of LRS files, I would not think that it can handle RES files, too. Maybe rename it to LazResourceEditor?

Yes, Sir! It will be here this noon. Thank you, @wp.
4
So maybe every form has a menu bar, and probably when you use a hamburger you will have an empty menu bar plus a hamburger button.
I guess it might look very peculiar.

Understood! Thank you very much, @CM630. Menu bar will be there, this noon. GMT+7
5
Yes, this is a known issue.

There is currently work by a contributor that should improve this.

Also 4.99 (future 5.0) can debug in a real console of your choice (and that will have the terminal support you need): https://forum.lazarus.freepascal.org/index.php/topic,74772.0.html
That works perfectly on my end. I have attached a screenshot for reference. Thank you all so much for your incredible work on this!
6
Debugger / Re: Debugging in a real terminal on Linux (Lazarus 4.99)
« Last post by Aruna on Today at 02:26:08 am »
Testers needed. The below should work with FpDebug and the gdb based backend.

Preparation: Open the project $(LazarusDir)/tools/unix_dbg_targetstarter/lazdebugtargetstarter.lpi and compile it. It should create an executable in its parent directory $(LazarusDir)/tools by the name of  (all lowercase) "lazdebugtargetstarter". This app must be present, and it must be in that directory.


If you use "Run parametern" (from menu "Run"), and check "Use launching application" and set it to your favourite terminal (should work for any terminal, if it can be started with an app to be run in it)
E.g.:
Code: Text  [Select][+][-]
  1. /usr/bin/gnome-terminal -t 'Lazarus Run Output' -- $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)

Important: It must have the "$(LazarusDir)/tools/runwait.sh" part. It wont work without that exact part. And, the project to be debugged must be the very next part on the command line.

In that case the debugger should open that terminal, and debug your app running in that terminal.
That works perfectly on my end. I have attached a screenshot for reference. Thank you all so much for your incredible work on this!
7
General / Re: How do I document the code correctly?
« Last post by Lauriet on Today at 02:01:54 am »
There has been a number of books that talk about good coding/documentation. In essence 1 procedure 1 purpose, and well named procedures would minimize the comments/documentation needed.

e.g.
if something then
  do something.
needs documentation.

if ItsRaining then
  TakeUmbrella

needs no documentation.

Let the code explain itself.
8
BTW, Pascal sets are ordinals by design (sequentially ordered and not sparse) and they have a simple solution because they can be exported to array. (which you can use internally?)

Sets are not ordinal — read the documentation.

The only types considered ordinal are: predefined integer types, subrange types, enumerated types, boolean types and character types.
9
Third party / Re: LRS Editor: A New Tool for Managing Lazarus Resource Files
« Last post by wp on Today at 01:18:24 am »
Full RES File Import & Export
I had wanted to suggest this feature, now it is here. But the application name is misleading now. An "LRS Editor" is expected to allow editing of LRS files, I would not think that it can handle RES files, too. Maybe rename it to LazResourceEditor?
10
General / Re: How do I document the code correctly?
« Last post by Hobbit00 on Today at 12:40:47 am »
I usually write documentation this way, at least for the most important objects.
For variables or class members and records, I limit myself to the "<summary>" entry and somtimes some "<remarks>"

This is a significant help in Delphi when writing code, as it produces a complete, speaking hint (see attachment) during use...
I normally use Delphi.
Code: Pascal  [Select][+][-]
  1. /// <summary>
  2. ///   Reads a text file and copies the contents between two markers into a byte array.
  3. ///   If there are multiple blocks, they are all copied.
  4. /// </summary>
  5. /// <remarks>
  6. ///   The file must be encoded in UTF8, the end of line must be the same as defined in current sLineBreak (platform dependent)
  7. /// </remarks>
  8. /// <returns>
  9. ///   Return: byte array on sucessfull, nil on failure
  10. ///   See also <see cref="TBytes"/> or <see cref="Array of bytes"/>.
  11. /// </returns>
  12. function ReadBytesBetweenMarkers(const AFileName: string; const StartMarker,
  13.                                  EndMarker: string): TBytes;
  14.  
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018