This sort of code is becoming possible now
Code: Select all
const spi_buffsize : word =100;
type proctype = procedure;
type spi_channel_type = record
head,
tail,
termflag,
match : byte;
empty,
full : boolean;
delimiter : string[5];
rx_buff,
tx_buff : array[0..spi_buffsize] of byte;
what_to_do : proctype;
end;
const
max_slave = 5;
var spi_channels : array[0..max_slave] of spi_channel_type;
this_channel : ^spi_channel_type;
spi_ik ,
spi_channel ,i,j : byte;
spi_txbuff : array[0..max_slave] of array[0..spi_buffsize] of byte;
spi_rxbuff : array[0..max_slave] of array[0..spi_buffsize] of byte;
spi_txhead,
spi_txtail,
spi_rxhead,
spi_rxtail : array[0..max_slave]of byte;
spi_termflag,
spi_match : array[0..spi_buffsize] of byte;
spi_rxb_empty,
spi_rxb_full : array[0..max_slave] of boolean;
spi_delimiter : array[0..max_slave] of array[5] of byte;
// whatever : array[3] of string[5]; // results in errors
//outstr : string[5];
procedure nothing;
begin
nop;
end;
begin
i := sizeof(max_slave);
i := sizeof(spi_buffsize);
i := sizeof(spi_channel_type);
i := 2;
j := 7;
this_channel := @spi_channels[1];
this_channel^.head := 8;
this_channel^.tx_buff[5] := 'x';
this_channel^.tx_buff[j] := 'x';
this_channel^.tx_buff[this_channel^.head] := 'x';
this_channel^.what_to_do :=@nothing;
this_channel^.tx_buff[this_channel^.head].3 := 1;
this_channel^.what_to_do^;
spi_rxbuff[i][j] := 'x';
end.