Le 20/12/2020 à 16:02, James Richters via fpc-pascal a écrit :
If I need a bunch of case statements, it's atcually worse than if I just have
separate procedures.
No, in fact the case statement is written only once, in the
implementation of TAxisRecord, and in procedure
Move_It(Axis_Letter:Ch
James, I remember going through some similar motions as you are. Looks like
you are searching for a form of indexing your record fields.
So many good suggestions, I had to join the fray and try something... My
preferred approach would also be an ordinal type for the axes and a
record variant, as al
Yes, I was trying to keep my data structure, because there were thousands of
occurrences ..
This project has had that structure since Turbo Pascal back in the 80s when it
only had 3 axis
It seemed like a good way to have variables all with the same name, and back
then it wasn't so bad to have
On 12/20/2020 7:11 AM, Luca Olivetti via fpc-pascal wrote:
Then change your data model.
Instead of
Axis_record = record
X,Y,Z,A,B,C : Double;
End;
use
AxisName = (X,Y,Z,A,B,C);
Axis_record = array[AxisName] of double;
then it's easy to do what you want.
procedure DoSomething(var Axis:
Thank you Luca, that will work much better for me!
James
-Original Message-
From: fpc-pascal On Behalf Of Luca
Olivetti via fpc-pascal
Sent: Sunday, December 20, 2020 10:11 AM
To: fpc-pascal@lists.freepascal.org
Cc: Luca Olivetti
Subject: Re: [fpc-pascal] Selecting Records with a
El 20/12/20 a les 16:02, James Richters via fpc-pascal ha escrit:
What I’m hopping to accomplish isn't to get it to work... it's to consolidate a
whole bunch of
functions and procedures that are all exactly the same except for which axis I
am working with...
I have 9 possible Axis, X,Y,Z,W,L.R
What I’m hopping to accomplish isn't to get it to work... it's to consolidate a
whole bunch of
functions and procedures that are all exactly the same except for which axis I
am working with...
I have 9 possible Axis, X,Y,Z,W,L.R,A,B,C
And I have Procedures:
Procedure Move_X;
Begin
DoSomethi
Am 20.12.2020 um 14:47 schrieb Tomas Hajny via fpc-pascal:
On 2020-12-20 11:56, Sven Barth via fpc-pascal wrote:
Am 20.12.2020 um 05:26 schrieb Jean SUZINEAU via fpc-pascal:
I know you don't like objects, but maybe something like :
Using modeswitch AdvancedRecords that also works with recor
On 12/19/20 10:02 PM, James Richters wrote:
No, this is just a simplified example..
ok...
The procedure will be working with dozens of records, so I need a way to call
the procedure and specify which element of all the records to use... it will
not be called for every element.
in that case, t
On 2020-12-20 11:56, Sven Barth via fpc-pascal wrote:
Am 20.12.2020 um 05:26 schrieb Jean SUZINEAU via fpc-pascal:
I know you don't like objects, but maybe something like :
Using modeswitch AdvancedRecords that also works with record types.
And I'd suggest a case-statement as well. Anything
Am 20.12.2020 um 05:26 schrieb Jean SUZINEAU via fpc-pascal:
I know you don't like objects, but maybe something like :
Using modeswitch AdvancedRecords that also works with record types.
And I'd suggest a case-statement as well. Anything else will only be
slower or just as fragile.
Regard
I know you don't like objects, but maybe something like :
unit uAxisRecord;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
{ TAxisRecord }
TAxisRecord
=
object
X,Y,Z,A,B,C: Double;
function Value_from_Letter( _A
wkitty42--- via fpc-pascal
Sent: Saturday, December 19, 2020 8:26 PM
To: fpc-pascal@lists.freepascal.org
Cc: wkitt...@windstream.net
Subject: Re: [fpc-pascal] Selecting Records with a variable
On 12/19/20 7:16 PM, James Richters via fpc-pascal wrote:
> Is there some syntax that would work to sel
On 12/19/20 7:16 PM, James Richters via fpc-pascal wrote:
Is there some syntax that would work to select the correct record based on the
variable so I can avoid having all the If statements?
do you need to show only one at a time or are you looping through and printing
all of them each time?
The best way to explain what I'm hoping to do is by example...
Say I have this record:
Type
Axis_Record = Record
X,Y,Z,A,B,C: Double;
End;
Var
AxisValue : Axis_Record;
Instead of this:
Procedure ShowAxis(Axisletter:Char);
Begin
If AxisLetter = 'X' Then
Writeln(AxisValue.X);
15 matches
Mail list logo