November 28, 2020, 02:07:03 PM

Author Topic: [bb] VB InstrRev() command by Jim Teeuwen [ 1+ years ago ]  (Read 626 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] VB InstrRev() command by Jim Teeuwen [ 1+ years ago ]
« on: June 29, 2017, 12:28:43 AM »
Title : VB InstrRev() command
Author : Jim Teeuwen
Posted : 1+ years ago

Description : This one works just like the Instr() command, but it starts the search for the substring at the end of the sourcestring in stead of the front.

Handy for cutting off the filename from a complete systempath.


Code :
Code: BlitzBasic
  1. ;// Usage: InStrRev(String$, Substring$[, Start%])
  2.  
  3. ;// String: The source in wich to look
  4. ;// Substring: The string for wich to look
  5. ;// Start(optional): The numeric position, counted from the left,
  6. ;// which defines where to start the search for the substring.
  7.  
  8. ;// ### EXAMPLE ##################################
  9. mystring$=InstrRev("c:litz3Dlitz3d.exe","",1)
  10. print "The filename is: "+mystring$
  11.  
  12. ;// output
  13. The filename is: blitz3d.exe
  14.  
  15. ;// ### THE GOODS ################################
  16.  
  17. Function InstrRev$(sT$,sS$,index=0)
  18.         While (Instr(sT$,sS$)>0)
  19.                 If Instr(sT$,sS$)>0 Then
  20.                         sT$=Mid$(sT$,Instr(sT$,sS$)+1)
  21.                 EndIf
  22.         Wend
  23.         If index=0 Then sT$=sS$+sT$
  24.         Return sT$
  25. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal