PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: GetFileTimeStamp()[Next]: GetIdPrepare()
\ -> Rexx -> Inbuilt PPWIZARD Functions -> GetId()


This is an inbuilt function function provided by PPWIZARD.

This function is produces a unique string from your text and can ensure that the new string only contains "valid" characters and can be limited in length.

This can be useful when you wish to use a value as a key of some sort. For the value that you pass, this routine will determine a unique key (or ID) of the format you requested.

The routine has a memory and will always return the same ID for the same value.

Note that if you currently search array elements then you know that this is slow. Generating unique rexx variable names for a string allows you to save the information for "keyed" access, that is absolutely no searching required to locate the information!

The fastest and typically easiest way of generating a "key" is with the standard rexx "c2x()" built in routine. All characters generated by "c2x()" will be valid in a rexx variable name and as long as you prefix it with something alphabetic you will generate a valid rexx variable name. Its major deficiency is that it doubles the string length (not counting a constant prefix) and this can cause problems on some interpreters (not regina) which usually have variable name restrictions of 250 characters or so). Another major disadvantage is that if the key is visible (say if used to generate a filename) then it is absolutely cryptic (can also make debugging harder)!

My recommendation is that if you don't have length restrictions and the key is not visible (or you don't care what a filename looks like etc) then you would be crazy not to use "c2x()" as it is extremely fast, otherwise this "GetId()" routine should be used.

The function takes at least 3 parameters as follows:

  1. A handle that was previously prepared with GetIdPrepare().

  2. The type of ID you'd like, valid types being:

  3. The value for which you want an ID generated. This is case sensitive, to make case insensitive simply convert your value to either upper or lower case before calling this routine.

  4. Depending on the type of ID being generated there may be a 4th or other parameters.


;--- Example #1 ---
#evaluate ''   ^call GetIdPrepare 'PPW'^
#evaluate ''   ^call SetId 'PPW', '#define', "HashDef"^       ;;Set preferred ID
#evaluate ''   ^say GetId('PPW', 'MAXCHARS', 'define')^
#evaluate ''   ^say GetId('PPW', 'MAXCHARS', '#define')^
#evaluate ''   ^say GetId('PPW', 'MAXCHARS', 'define it')^
#evaluate ''   ^say GetId('PPW', 'MAXCHARS', 'define')^
#evaluate ''   ^say GetId('PPW', 'MAXCHARS', 'aaaaaaaaaaaaaaaa',, 10)^  ;;Max 10 chars
#evaluate ''   ^say GetId('PPW', 'MAXCHARS', 'aaaaaaaaaaaaaaab',, 10)^
#evaluate ''   ^say GetId('PPW', 'MAXCHARS', 'aaaaaaaaaaaaaaac',, 10)^
#evaluate ''   ^say GetId('PPW', 'MAXCHARS', 'aaaaaaaaaaaaaaaa',, 10)^

;--- Example #2 ---
#evaluate ''   ^call GetIdPrepare 'PPW'^
#evaluate ''   ^say GetId('PPW', '2_', '#define')^
#evaluate ''   ^say GetId('PPW', '2_', '#include', '#')^  ;;Allow Hash to be valid as well

email me  any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Search][Prev]: GetFileTimeStamp()[Next]: GetIdPrepare()

My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Saturday May 28 2022 at 2:55pm