Recent

Author Topic: declaring Array  (Read 2079 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 574
declaring Array
« on: March 14, 2026, 03:30:13 am »
try to define array
   BaudRateStrings: array[Integer] of string = ( '600','1200', '2400', '4800', '9600', '14400', '19200', '38400', '56000', '57600','115200', '128000', '230400', '256000');

fportsettings.pas(62,170) Error: Expected another 4294967282 array elements

i got error in other apps i define and works perfect i don't remember what unit add or component

cdbc

  • Hero Member
  • *****
  • Posts: 2728
    • http://www.cdbc.dk
Re: declaring Array
« Reply #1 on: March 14, 2026, 03:53:26 am »
Hi
Code: Pascal  [Select][+][-]
  1. BaudRateStrings: array of string = ( '600','1200', '2400', '4800', '9600', '14400', '19200', '38400', '56000', '57600','115200', '128000', '230400', '256000');
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

eldonfsr

  • Hero Member
  • *****
  • Posts: 574
Re: declaring Array
« Reply #2 on: March 14, 2026, 04:22:40 am »
Thanks

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1584
    • Lebeau Software
Re: declaring Array
« Reply #3 on: March 14, 2026, 06:13:42 am »
array of string is a dynamic array. Since you know the exact number of elements you need, a static array makes sense. You just need to specify the correct index bounds:

Code: Pascal  [Select][+][-]
  1. BaudRateStrings: array[0..13] of string = ('600', '1200', '2400', '4800', '9600', '14400', '19200', '38400', '56000', '57600', '115200', '128000', '230400', '256000');

Alternatively, use an enum:

Code: Pascal  [Select][+][-]
  1. BaudRate = (br600, br1200, br2400, br4800, br9600, br14400, br19200, br38400, br56000, br57600, br115200, br128000, br230400, br256000);
  2. BaudRateStrings: array[BaudRate] of string = ('600', '1200', '2400', '4800', '9600', '14400', '19200', '38400', '56000', '57600', '115200', '128000', '230400', '256000');
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

440bx

  • Hero Member
  • *****
  • Posts: 6382
Re: declaring Array
« Reply #4 on: March 14, 2026, 06:40:37 am »
Alternatively, use an enum:

Code: Pascal  [Select][+][-]
  1. BaudRate = (br600, br1200, br2400, br4800, br9600, br14400, br19200, br38400, br56000, br57600, br115200, br128000, br230400, br256000);
  2. BaudRateStrings: array[BaudRate] of string = ('600', '1200', '2400', '4800', '9600', '14400', '19200', '38400', '56000', '57600', '115200', '128000', '230400', '256000');
That's what he should use.  Much cleaner, explicit and easier to maintain.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

LeP

  • Full Member
  • ***
  • Posts: 245
Re: declaring Array
« Reply #5 on: March 14, 2026, 10:03:21 am »
Add also these value, they are commonly supported and used:
 br460800, br921600
 '460800', '921600'
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

Thaddy

  • Hero Member
  • *****
  • Posts: 18982
  • Glad to be alive.
Re: declaring Array
« Reply #6 on: March 14, 2026, 01:24:11 pm »
You should ad br300 which was fastest around the mid to end of the '70's
Then at least 4294967282 becomes 4294967281.
But yes, of course, either count the exact number of elements or use a dynamic array.
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

eldonfsr

  • Hero Member
  • *****
  • Posts: 574
Re: declaring Array
« Reply #7 on: March 19, 2026, 03:09:42 am »
Thanks for your guide i did....as you show me here..
 

 

TinyPortal © 2005-2018