Yogesh Chauhan's Blog

How to use [] (square brackets) function in Envision Basic?

in Envision Basic on December 24, 2021

The [] (square brackets) function helps extract or replace any strings.

Syntax

These are more like usages than syntaxes but we can use it like these:

Where

  • num.expr1 is the starting position for the operation.
    • It refers to the character position where the replacement or extraction operation occurs.
  • num.expr2 is the number of characters involved in the operation.
    • For an extraction, UniData returns that number of characters.
    • For a replacement, UniData replaces that number of characters.

str.expr [num.expr1,num.expr2] = expr

In the usage above, the square bracket function replaces part or all of str.expr.

OR


expr = str.expr [num.expr1, num.expr2]

In the usage above, the square bracket function extracts part or all of string.expr.

OR


expr = str.expr [num.expr1] 

In the first form, the function replaces part or all of string.expr. In the
second form, the function extracts part or all of string.expr

When a null value is passed a command parameter where a number is expected for e.g (num.expr1, num.expr2) and if you have null value handling ON, you’ll get a warning message and UniBasic will use 0 as the value.

Examples

Extract the first character of the variable

F.INITIAL will have “S” stored as its value.


FIRST.NAME = 'Sam'
F.INITIAL = FIRST.NAME[1,1]

Change the first letter of the word

The resulting string will be “Merry Christmas”.


TITLE = 'Merry Xhristmas'
TITLE[7,1] = 'C'


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How get_template_part helps write reusable code in WordPress?WordPressHow to Write Complex Search Queries in SQL?SQL/MySQLHow to compile and watch Sass using Gulp in WordPress?SCSSHow to show slider value in HTML5 range input using JavaScript?HTMLHow to remove special characters (dash, asterisk etc) from any string in PHP?PHPHow to get start index and end index (as int) of substring in Swift?Swift