Recent

Author Topic: Reverse function of "ord" [SOLVED]  (Read 1274 times)

mercurhyo

  • Full Member
  • ***
  • Posts: 201
Re: Reverse function of "ord"
« Reply #15 on: April 29, 2021, 04:55:08 pm »
no pb @pascal111 I just want to let you kno, as i developped a massive "A"llergia around 'MS' for 25 years, there are other basic compilers even multiplatfarm which have dialects much more better than 'MS' and compatible with. xblite, FreeBasic, etc etc... each of them have features and flavor picked from other languages or new to them
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geoforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

mercurhyo

  • Full Member
  • ***
  • Posts: 201
Re: Reverse function of "ord"
« Reply #16 on: April 29, 2021, 05:00:16 pm »
so in FreeBasic there are enum and they even are "overloadable" like operators LOL! just ask googooole "FreeBasic enum" have fun
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geoforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Reverse function of "ord"
« Reply #17 on: April 29, 2021, 05:10:24 pm »
I got your aim @mercurhyo, and I meant that originally BASIC takes its new features from Pascal, and this what makes the specialty of some new BASIC versions.

Handoko

  • Hero Member
  • *****
  • Posts: 4285
  • My goal: build my own game engine using Lazarus
Re: Reverse function of "ord"
« Reply #18 on: April 29, 2021, 05:46:15 pm »
BASIC have many compilers/IDEs and some of them are pretty good. FreeBASIC, Gambas, QB64, B4A, etc. I can tell why in some areas they are better then Lazarus/FPC as I can tell you why Lazarus is better too. Each of them has their own strength.

I learned programming started with BASIC. I abandoned it to Pascal because they run extremely slow on my 8088 machine. Pascal run several times faster and it allowed me to direct accessing the hardware. But that only happened in many many years ago. A lot of improvements have been added in the modern BASIC compilers and the performance is greatly improved.

One of the advantages of using BASIC is, it is very easy to start with. Especially for learning to write games. If you search how to use QB64 to build games in Youtube, you will know it requires only average math skill and basic logic abilities. Use the right tool for the right job. Learning how to build games in Lazarus? Well, you should start with choosing which graphics library to use, how to install a third party library, learn some basic of OOP, understand event-driven programming concept before you write your first line to develop the game. For beginners want to learn how to write games, I will say don't start with Pascal.

Both BASIC and Pascal have been existed for more than half century and still alive. They really have reasons to stay alive.
« Last Edit: April 29, 2021, 06:05:16 pm by Handoko »

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Reverse function of "ord"
« Reply #19 on: April 29, 2021, 06:05:51 pm »
As @Handoko said, yes, BASIC is easy to start with and now it has special versions can't be compared with the original traditional BASIC for the big differences between 'em, but to gain more power we need to learn Pascal. We can say for the complexity of Pascal that for every pleasure there is a price. For example, I think they learn data structures in academic computer science college, and until now I didn't get the idea of it, and although it's complex thing in computer science but it needs strong languages like Pascal and C, I think we can't perform such concept in language like BASIC.

lucamar

  • Hero Member
  • *****
  • Posts: 4009
Re: Reverse function of "ord"
« Reply #20 on: April 29, 2021, 06:32:35 pm »
For example, I think they learn data structures in academic computer science college, and until now I didn't get the idea of it, and although it's complex thing in computer science but it needs strong languages like Pascal and C, I think we can't perform such concept in language like BASIC.

You can do all that even in BASIC, though it's debatable whether it's worth the effort :D

But yes, I've seen rather complex structures implemented in (granted, barely legible) BASIC
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

howardpc

  • Hero Member
  • *****
  • Posts: 3715
Re: Reverse function of "ord"
« Reply #21 on: April 29, 2021, 06:40:36 pm »
I still hope for the day when FPC provides an intrinsic Count function that would return the number of included items, and for the time when sets of >256 elements are supported. Perhaps these are in the pipeline.
Ahum,,? https://www.freepascal.org/~michael/docs-demo/material/system/popcnt/ works on sets too.
Indeed popcnt() can be applied to various differently-sized sets, provided you know the set size.

But AFAIK FPC still lacks a single built-in routine returning the cardinality of a set of unknown size (since the memory footprint of a set is an implementation detail). You have to roll your own, as PascalDragon demonstrated back in 2018.

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Reverse function of "ord"
« Reply #22 on: April 29, 2021, 06:43:49 pm »
For example, I think they learn data structures in academic computer science college, and until now I didn't get the idea of it, and although it's complex thing in computer science but it needs strong languages like Pascal and C, I think we can't perform such concept in language like BASIC.

You can do all that even in BASIC, though it's debatable whether it's worth the effort :D

But yes, I've seen rather complex structures implemented in (granted, barely legible) BASIC

I googled for that in FreeBASIC as an example and saw some of these features in FreeBASIC forum.

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Reverse function of "ord"
« Reply #23 on: April 29, 2021, 07:01:18 pm »
Sets are indeed a Pascal gem. I've never understood why many other languages lack built-in language support for sets.
Not that Pascal's support for sets could not be improved.
I still hope for the day when FPC provides an intrinsic Count function that would return the number of included items, and for the time when sets of >256 elements are supported. Perhaps these are in the pipeline.

We can do handmade function like next one:

Code: Pascal  [Select][+][-]
  1. function set_count(e:set_of_enum_x):integer;
  2.  
  3.  
  4. var
  5.  
  6.   i:enum_x;
  7.   x:integer;
  8.  
  9. begin
  10.  
  11.   x:=0;
  12.  
  13.   for i:=low(enum_x) to high(enum_x) do
  14.   if (i in e) then inc(x);
  15.  
  16.   set_count:=x;
  17. end;
  18.  
  19.  

Code: Pascal  [Select][+][-]
  1.  
  2. unit Unit1;
  3.  
  4. {$mode objfpc}{$H+}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     procedure FormCreate(Sender: TObject);
  17.   private
  18.  
  19.   public
  20.  
  21.   end;
  22.  
  23.   enum_x=(a,b,c,x,y,z);
  24.   set_of_enum_x = set of enum_x;
  25.  
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30.  
  31.  
  32. function set_count(e:set_of_enum_x):integer;
  33.  
  34. implementation
  35.  
  36. {$R *.lfm}
  37.  
  38.  
  39. function set_count(e:set_of_enum_x):integer;
  40.  
  41. var
  42.  
  43.   i:enum_x;
  44.   x:integer;
  45.  
  46. begin
  47.  
  48.   x:=0;
  49.  
  50.   for i:=low(enum_x) to high(enum_x) do
  51.   if (i in e) then inc(x);
  52.  
  53.   set_count:=x;
  54. end;
  55.  
  56. { TForm1 }
  57.  
  58. procedure TForm1.FormCreate(Sender: TObject);
  59.  
  60. var
  61.   h_set:set_of_enum_x;
  62.   count:integer;
  63.   s:string;
  64.  
  65. begin
  66.  
  67.   h_set:=[];
  68.   h_set:=h_set+[x,a,c];
  69.  
  70.   count:=set_count(h_set);
  71.   str(count,s);
  72.   showmessage(s);
  73. end;
  74.  
  75. end.
  76.  
  77.  
  78.  

 

TinyPortal © 2005-2018