Recent

Author Topic: Conditional variable definition?  (Read 3001 times)

alpine

  • Hero Member
  • *****
  • Posts: 1372
Re: Conditional variable definition?
« Reply #30 on: February 01, 2025, 11:39:57 am »
Opps, up..., indeed it should be MemHandle:=cbWinBufAlloc (Count,Bitness);
You're welcome.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Warfley

  • Hero Member
  • *****
  • Posts: 1870
Re: Conditional variable definition?
« Reply #31 on: February 01, 2025, 01:59:40 pm »
As it seems that no one has put the obvious solution yet: generics
Code: Pascal  [Select][+][-]
  1. procedure Foo(Bitness: Integer);
  2. generic procedure doFoo<T>;
  3. var arr: Array of T;
  4. begin
  5.   ...
  6. end;
  7.  
  8. begin
  9.   case Bitness of
  10.     16: specialize doFoo<Word>;
  11.     32: specialize doFoo<Cardinal>;
  12.     otherwise raise Exception.Create('Unknown Bitness');
  13.   end;
  14. end;

alpine

  • Hero Member
  • *****
  • Posts: 1372
Re: Conditional variable definition?
« Reply #32 on: February 01, 2025, 06:29:38 pm »
As it seems that no one has put the obvious solution yet: generics
Did you look at the interface of the wrapped library? How do you think the generics will help?
The main problem of the OP is that he doesn't know how to unpack the DAQ buffer. His question is related to his own idea of ​​how to solve it. Any advanced features are unnecessary, he just need a little more understanding of the data memory layout.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

 

TinyPortal © 2005-2018