String LastIndexOf
Gets the last index of a substring.
Syntax
| LastIndexOf( string str, string substring ) | 
Parameters
| str | string | The specified string to seek. | 
| substring | string | The sub string to locate in str string. | 
Return Values
| Returns the last index of the substring in the str string, as an integer. | 
Copy
                                            
                                        
                                        Example SMC
                                            --This program will demonstrate the LastIndexOf method. 
        
--File location path assigned to location string variable
location = "/mnt/SMC/custom"
--Opens a binary file name called "myfile" in write mode
file1 = File.OpenBinaryFile(location.."/myfile", FileMode.Write) 
--Write "ScanMaster ScanScript" string to "myfile" 
file1.Write(String.GetBytes("ScanMaster ScanScript"))
--Close the written file
file1.Close() 
f1= File.OpenBinaryFile(location.."/myfile", FileMode.Read)    
-- Read the whole file and return as byte array
readFile = f1.ReadToEnd()
--Display the file size
Report(f1.Length()) 
--Display the contents of the file
Report(readFile.GetString()) 
--Display the index of "c" in the specified string
Report(string.LastIndexOf(readFile.GetString(),"c"))
                                            
Copy
                                            
                                        
                                    Example EC1000
                                            --This program will demonstrate the LastIndexOf method. 
        
--File location path assigned to location string variable
location = "Disk\\custom"
--Opens a binary file name called "myfile" in write mode
file1 = File.OpenBinaryFile(location.."\\myfile", FileMode.Write) 
--Write "ScanMaster ScanScript" string to "myfile" 
file1.Write(String.GetBytes("ScanMaster ScanScript"))
--Close the written file
file1.Close() 
f1= File.OpenBinaryFile("Disk\\custom\\myfile", FileMode.Read)    
-- Read the whole file and return as byte array
readFile = f1.ReadToEnd()
--Display the file size
Report(f1.Length()) 
--Display the contents of the file
Report(readFile.GetString()) 
--Display the index of "c" in the specified string
Report(string.LastIndexOf(readFile.GetString(),"c"))