Recent

Author Topic: Getting a true variant parameter possibility.  (Read 917 times)

440bx

  • Hero Member
  • *****
  • Posts: 6023
Re: Getting a true variant parameter possibility.
« Reply #15 on: November 11, 2025, 11:41:22 pm »
Inspecting the COBOL code and also the data definition you posted and your later comments, it looks like you simply want to log the routine name (paragraph in COBOL), a variable name (TRACE-ALPHA) and a single value (TRACE-NUM).

if that's the case then you don't need an array of const.  A procedure that takes 3 parameters is all you need and, the procedure can log the values somewhere (in Pascal a simple array of records might do and using the "with" statement would take care of the need to qualify the record.)

By the way, the "paragraph name", what is the procedure/function name in Pascal can be obtained using {$I %CURRENTROUTINE%} that way you don't even have to manually code that (and change the code if you decide to change the name later on for whatever reason.)

Also, your COBOL definition and code are limited to logging a single variable type, that is, Var must be a numeric value.  With FPC and using overloads, you could log any data type without using array of const just by overloading the logging function/procedure (one per type.)  However that would require your data type to keep track of what type is stored in that particular array element (you would most likely need to declare a variant to keep track of that.)

As usual, the best solution can only be found once complete knowledge of the problem is reached ;)

HTH.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018