ajBigStrReplace function
Description
Replaces part of a Big String text with a different text string.
Syntax
ajBigStrReplace(old_memory_id, start_num, num_chars, new_memory_id, [run_condition], [run_by_function_point_only])
Argument Name | Argument Type | Description |
---|---|---|
old_memory_id (big string ID) (required) | String | The ID of the big string you want to replace some characters. A big string ID can be retrieved from ajBigStrSet() or configure Big String value from More Tools tab in AlchemyJ ribbon. |
start_num (required) | Long | It is the position of the character in old_memory_id that you want to replace with Big String text defined using new_memory_id. |
num_chars (required) | Long | It is the number of characters in old_memory_id that you want to replace. |
new_memory_id (big string ID) (required) | String | It is the Big String text that will replace characters in old_memory_id. |
run_condition (optional) | Boolean | The function will run when the value is TRUE. Otherwise will not run. The default value is TRUE. |
run_by_function_point_only (optional) | Boolean | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Preview Function Point. If it equals TRUE, the function can be executed with Preview Function Point (AlchemyJ ribbon \ Preview Function Point) only. The default value is TRUE. |
The function will return:
1) Return Value: Big String
2) Return Type: Single Value
Example
In this example, we will demonstrate how to replace part of a Big String text with a different text string. In this example, we would be using the word 'funny' and transform it to the word 'friendly'. This is done by replacing 'unn' with 'riendl'.
The original Big String value we have used here is 'funny'. To use the ajBigStrReplace formula, firstly we have to convert 'funny' into a Big String old big string ID. This is done using the ajBigStrSet formula. Next, we also have to convert the replacement text 'riendl' into a new big string ID.
We can then use the formula as shown in B13 and it will return a Big String value.
To verify the result, we can use the ajBigStrValue formula in B15 to make it into a normal String. As seen in B16, we have successfully transformed the word from 'funny' to 'friendly' by replacing part of the Big String.
Error Scenarios
It will return #VALUE! when missing any required parameter or mismatch parameter type. Besides, system will also raise error for below scenario(s).
Error Scenario |
---|
Big String ID does not exist. |
Start num should be greater than zero. |
Num chars should be greater than or equal to zero. |
New big string ID does not exist. |