سؤال

I need to convert a huge number of constants from an application. Is it possible to get all the constants declared in a unit and their values, other then parsing the .pas file?

هل كانت مفيدة؟

المحلول

It seems that this is not possible without parsing your unit and extract the constants. During the compilation constants are replaced by value, so it is impossible to get the value from them at runtime.

LE: maybe there is someone who can explain this in depth.

نصائح أخرى

There is the Open Tools API to work with the IDE in an object oriented way. But I think it is not possible to list the constants of files.

I think the easiest way is to use grep or other similar RegEx program that can collect the string constants from files: ^\s*\w+\s*=\s*'.+?'\s*[;#\{\+]

How about changing all CONST to ResourceString, re-building, and then dump the string resources using a resource editor like XN Resource Editor? That's how I'd approach it, if there were really THAT many of them.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top