#1 2022-11-15 23:12

jogiwer
Member
From: Germany
Registered: 2022-11-05
Posts: 66

Questions on Pascal Script

Accessing array elements

Is it possible to directly select an element of an array returned by a function? I had problems using these:

Match := SubMatchesRegEx(Input, Find, True)[2];
Name := GetMarkedFiles[5];
Name := GetMarkedFiles()[1];

So I first had to assign the array to a variable of type TWideStringArray.

Retrieving names of enumeration members

I build an enum type for the different log levels. To compare them I use Ord(LogLevel). But printing their names wasn't as expected. I had to build a lookup array:

type
  TLogLevel = (FATAL, ERROR, WARN, INFO, DEBUG, TRACE);

const
  LOG_LEVEL_NAMES = 'FATAL,ERROR,WARN,INFO,DEBUG,TRACE';

var
  Logging_LogLevelToStr: TWideStringArray;
  LogLevel: TLogLevel;
  LevelText: WideString;

begin
  Logging_LogLevelToStr := WideSplitString(LOG_LEVEL_NAMES, ',');
  LogLevel := DEBUG;

  LevelText := Logging_LogLevelToStr[Ord(LogLevel)];
end.

How to improve this? Found texts about TypeInfo from typinfo. But these were not working ...

Last edited by jogiwer (2022-12-06 23:31)

Offline

#2 2022-11-19 19:12

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,370

Re: Questions on Pascal Script

jogiwer wrote:

Accessing array elements

You'll need to assign the returned array to a variable, and then you can access individual elements through that variable. No shortcuts here unfortunately.

jogiwer wrote:

Retrieving names of enumeration members

Pascal Script supports only some of the features normally found in proper compilers, and type information isn't one of them.

Offline

#3 2022-11-19 21:06

jogiwer
Member
From: Germany
Registered: 2022-11-05
Posts: 66

Re: Questions on Pascal Script

OK, so I did it the best way I actually could handle it.

Unfortunately documentation about Pascal Script is hard to find. Most questions are answered on Pascal itself. But it seems undocumented what Pascal Script is not able to do.
So the only way proof some code fragments its just by putting them into the scripts smile

There also seems to be no IDE for Pascal Script either - so I'm stuck to ReNamer.

Offline

Board footer

Powered by FluxBB