Two things I want to get:
Length of some string NAME
some substrings of NAME (ie: first 5 characters, last 3 characters, etc)
Is this possible? How to accomplish?
The Forum is up for sale: XeNTaX Forum looking for new owner
quickbms string operations
-
chrrox
- Moderator
- Posts: 2602
- Joined: Sun May 18, 2008 3:01 pm
- Has thanked: 57 times
- Been thanked: 1411 times
Re: quickbms string operations
read the help file included in quickbms?
just look up
String VAR OP VAR
just look up
String VAR OP VAR
-
finale00
- M-M-M-Monster veteran

- Posts: 2382
- Joined: Sat Apr 09, 2011 1:22 am
- Has thanked: 170 times
- Been thanked: 307 times
Re: quickbms string operations
How can I combine the operations to determine if a substring is part of a string?
ie: determining whether the "." character is in some string, and possibly the index.
ie: determining whether the "." character is in some string, and possibly the index.
-
AlphaTwentyThree
- double-veteran

- Posts: 982
- Joined: Mon Aug 24, 2009 10:55 pm
- Has thanked: 76 times
- Been thanked: 658 times
Re: quickbms string operations
If it's only one character, you can just scan through the string:
You'll also get the position of the character with this (variable i). It's a bit tricky to work with strings with QuickBMS. 
Do you really need to check for a string of length more than one? What exactkly do you want to do? Your example with the "." reminds me of "splitting file name and extension if there is one".
Code: Select all
set NAME "TEST.bmp"
set DETECT 0x2e # needs to be the hex representation
callfunction searchstring 1
startfunction searchstring
strlen NAMEL NAME
set EXISTS 0
for i = 0 < NAMEL
getVarChr T NAME i
if T == DETECT
set EXISTS 1
break
endif
next i
endfunctionDo you really need to check for a string of length more than one? What exactkly do you want to do? Your example with the "." reminds me of "splitting file name and extension if there is one".
If you like what you see, why not click the little Thank You button?
It will definitely motivate me! 
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks
- aluigi
- VVIP member

- Posts: 1916
- Joined: Thu Dec 08, 2005 12:26 pm
- Location: www.ZENHAX.com
- Has thanked: 4 times
- Been thanked: 661 times
- Contact:
Re: quickbms string operations
in your example of the dot if you want to know directly the extension of a filename located in a variable (like set VAR string "myfile.txt") you can just use:
set EXT extension VARIABLE
the String command can be used to do search operations but sometimes it's a bit complex and in some cases I'm still undecided on the return value.
for example if you want something like strchr you can just use the '&' operator or just "strchr" (it's the same since it's an alias):
set NAME string "myfile.txt"
set TMP string NAME
string TMP &= "."
in this case TMP will be ".txt"
you can do all the tests you want just like I did simply writing these example scripts and then placing a print command at the end, like:
print "result: %TMP%"
set EXT extension VARIABLE
the String command can be used to do search operations but sometimes it's a bit complex and in some cases I'm still undecided on the return value.
for example if you want something like strchr you can just use the '&' operator or just "strchr" (it's the same since it's an alias):
set NAME string "myfile.txt"
set TMP string NAME
string TMP &= "."
in this case TMP will be ".txt"
you can do all the tests you want just like I did simply writing these example scripts and then placing a print command at the end, like:
print "result: %TMP%"
