Jul 22, 2011 Replies: 205 Updated: 3/14/2014 - Version 1.05, This new version has 14 new functions/commands. Please report any issues. The new functions/commands are underlined and listed below in the updated docs. Updated: 9/19/2013 - Version 1.04, Corrected an error in the Mid() function when retrieving the last character. Updated: 8/28/2013 - Version 1.03, Added code to stop OutOfBounds error on the Mid Function. This would happen when an invalid index was passed to the function. Also corrected a bug that was in the DayOfMonth Function in versions prior to 1.02. Updated: 4/5/2013 Added new date functions and a simple Encrypt and Decrypt Function. NOTE: A few older Functions were renamed. StringFunctions use function names that are closer to the VB commands and may help beginners when they start programming in B4A. I wrote them for that reason when I started. These functions use to be in a code module but have now been converted to a Library. This has the new inline syntax and help as you start to type the command. Requires B4A 2.5 or Higher Copy the StringFunctions.jar and StringFunctions.xml to the Extra Libraries folder. Be sure to DIM the Lib object like Below. You can use any variable name in place of sf in the Example below. Code: Sub Globals Dim sf As StringFunctions sf.Initialize End Sub StringFunctions Version 1.05 AsciiCodes Displays a MessageBox with all Characters and their ASCII codes. AddSpaces (HowMany As Int) As String Returns a string of spaces. The number returned is set by HowMany. At (YourString As String, SearchFor As String)) Returns the position of the SearchFor within YourString. CurrentWeek (MyDate As String) As Int Returns the number of the current week, 1-52 from the date passed to MyDate. DayOfMonth (MyDate As ) As Int Returns the day of the month like 1-31, from the date passed to MyDate. Decrypt (YourText As String) As String Converts an encrypted string of text to readable format, no key is needed. Empty (StringText As String) As Boolean Test to see if the string is empty and returns True if it is, otherwise returns False. Encrypt (YourText As String) As String Converts a string of text to simple encryption, no Key is needed. EraseData This will erase all data saved with the SaveData function stored in the temporary vault. FileExist (PathAndFileName As String) As Boolean Returns True if the filename passed does exist, otherwise returns False. Be sure to include the path like: If FileExist("/mnt/sdcard/mydata.dat") Then MsgBox("Yes", "The Answer") GetData (Key As Object) As Object Gets data from the temporary vault. EditText1.Text = SF.GetData("EnteredName") The Key is case sensitive. InString (YourString As String, SearchFor As String)) Returns the position of the SearchFor within YourString. IsEmpty (StringText As String) As Boolean Test to see if the string is empty and returns True if it is, otherwise returns False. Left (StringText As String, Length As Long) As String Returns the Left portion of a string with the number of characters passed in Length. Len (StringText As String) As Long Returns the length of the string. ListToString (YourList As List, Sorted As Boolean, Ascending As Boolean) As String Converts a List object to a String. ListToStringArray (YourList As List, Sorted As Boolean, Ascending As Boolean) As String() Converts a List object to a String Array. Lower (StringText As String) As String Returns the string converted to Lowercase characters. Ltrim (StringText As String) As String Returns a new string with the leading spaces removed. MB (Message As String) Same as MsgBox but only needs one parameter. Mid (StringText As String, Start As Int, Length As Int) As String Returns the a new String for how ever many characters passed in Length from a starting position passed in Start. Example: Mid("This is a long line of text", 5, 2) In this example the function will Return: "is" MidExtract (StringText As String, Start As String, EndAt As String) As String Used to extract text from a string between to other blocks of text. Ans = MidExtract("Dr. Jim Joe Brown", "Jim", "Brown") 'Returns: Joe Ans = MidExtract("Dr. Jim [Joe] Brown", "[", "]") 'Returns: Joe MidS (StringText As String, StartAt As Int) As String Works like the Mid$ function in Visual Basic. Month (MyDate As String) As Int Returns the number of the current month 1-12 as Int type, from the date passed to MyDate. MonthName (MyDate As String) As String Returns the Name the current month as a String like January, etc., from the date passed to MyDate. NewDate (DatePassed As String, HowManyDays As Int) As String Returns a new date adding or subtracting HowManyDays. HowManyDays can be positive or negative numbers. NumOfDaysBetween (CurrentDate As String, OtherDate As String) As Int Returns the numbers of days passed between the two dates passed. Pad (Text As String, PadWith As String, Length As Int, Post As Boolean) As String Used to pad a string with a selected character. If Post = True the padding will follow any text in the string, if Post = False, the padding will be before the text. Length is the total length for the padded string. PadWith is the selected character to use for the padding. SF.Pad("Jimmy Joe", "*", 20, True) 'Returns "Jimmy Joe***********" Proper (StringText As String) As String Returns the string in proper format. Example: MyText = "jim joe brown" MyText = SF.Proper(Mytext) This function will return: "Jim Joe Brown" Replicate (mChar As String, Times As Int) As String Repeats any character passed, a selected number of Times. Right (StringText As String, Length As Long) As String Returns the Right portion of a string with the number of characters passed in Length. RndChrGen (StringLength As Int, CharacterType As Int) As String Returns a string of ramdom characters with a length specified by StringLength. CharacterType tells the function what type of characters to return. CharacterType = 0 for Upper and Lower case CharacterType = 1 for Upper case only CharacterType = 2 for Lower case only Rtrim (StringText As String) As String Returns a new string with the trailing spaces removed. SaveData (Key As Object, Data As Object) Save data passed in a temporary file. SF.SaveData("ScreenTitle", MyVar) or SF.SaveData("EnteredName", EditText1.Text) ScrInfo ( As Pect) As Int Returns information about the devices screen. You can pass these parameters: Pass "W" for Width Pass "H" for Height Pass "S" for Scale Pass "D" for DPI Call like: SF.ScrInfo("W") SearchDate (Date1 As String, Date2 As String, DateRange As Int) As Boolean Returns True if the Date1 and the Date2 are within x Days(DateRange) of each other. Pass the dates as Strings. Example: SearchDate("03/01/2013", "02/15/2013", 30) Split (CurrentString As String, Split_At_Delimiter As String) As List Returns a LIST of items from the string split at the Delimiter. EXAMPLE: Dim ANS As List ANS = SF.Split("This is a test string.", " ") SplitGetWord (CurrentString As String, Split_At_Delimiter As String, GetElement As Int) As String Returns just the one element selected with GetElement from the string. EXAMPLE: ANS = SF.SplitGetWord("This is a test string.", " ", 2) In this example the function will Return: "is" StrArraySort (StringArray() As String, Ascending As Boolean) As String() Used to sort a String Array. Sort will be in Ascending order if Ascending = True. StringArrayToList (StringArray() As String, Sorted As Boolean, Ascending As Boolean) As List Converts a String Array to a List object. StringToList (StringText As String, Sorted As Boolean, Ascending As Boolean) As List Convert a String to a List object. This will split the string between words. Stuff (CurrentText As String, InsertInString As String, RemoveFromString As String) As String Used to replace text in a string with new text. Example: MyText = "I will tell you that joe is a good friend!" MyText = SF.Stuff(MyText, "Joe Brown", "joe") This function will return: "I will tell you that Joe Brown is a good friend!" Today () As String Returns the devices date. Trim (Text As String) As String Returns a new string with leading and trailing spaces removed. Upper (StringText As String) As String Returns the string converted to Uppercase characters. Val (StringText As String) As Double Returns the numerical value of a string. If the string contains now value it returns 0. ValidDate (ChkDate As ) As Boolean Returns True if the date passed is a Valid date. WeekDay (MyDate As String) As String Returns the number of the day of the week 1-7 as a String, from the date passed to MyDate. WeekName (MyDate As String) As String Returns the name of the day of the week like Sunday, Monday, etc., from the date passed to MyDate. Year (MyDate As String) As String Returns the year of the date passed in MyDate. Example: SF.Year("01/01/2013") returns "2013" getSDCardPath () As String Returns external/physical SD Card directory. This function may not return the correct store on an Android OS above 4.1. This is due to changes made to the OS system in the newer versions. Returns "", if the store can not be read. iif (Value1 As String, Value2 As String, Value3 As String) As String This is a single line if conditional test. If Value1 is true, Value2 is returned, otherwise Value3 will be returned. Works with strings and booleans. Example: MsgBox(iif("Bob"="Jim", "They are the same", "They are not the same"), "The Answer") or MyBoolean = iif(FirstTime = True, StartMyService = True, StartMyService = False) Attachments StringFunctions 1.0.zip StringFunctions 1.0.zip 5.8 KB · Views: 3,046 StringFunctions 1.01.zip StringFunctions 1.01.zip 7.3 KB · Views: 2,671 StringFunctions 1.03.zip StringFunctions 1.03.zip 7.4 KB · Views: 2,024 StringFunctions 1.04.zip StringFunctions 1.04.zip 7.6 KB · Views: 3,251 StringFunctions 1.05.zip StringFunctions 1.05.zip 10.6 KB · Views: 9,559 Last edited: Mar 21, 2014 Click to expand...
Updated: 3/14/2014 - Version 1.05, This new version has 14 new functions/commands. Please report any issues. The new functions/commands are underlined and listed below in the updated docs. Updated: 9/19/2013 - Version 1.04, Corrected an error in the Mid() function when retrieving the last character. Updated: 8/28/2013 - Version 1.03, Added code to stop OutOfBounds error on the Mid Function. This would happen when an invalid index was passed to the function. Also corrected a bug that was in the DayOfMonth Function in versions prior to 1.02. Updated: 4/5/2013 Added new date functions and a simple Encrypt and Decrypt Function. NOTE: A few older Functions were renamed. StringFunctions use function names that are closer to the VB commands and may help beginners when they start programming in B4A. I wrote them for that reason when I started. These functions use to be in a code module but have now been converted to a Library. This has the new inline syntax and help as you start to type the command. Requires B4A 2.5 or Higher Copy the StringFunctions.jar and StringFunctions.xml to the Extra Libraries folder. Be sure to DIM the Lib object like Below. You can use any variable name in place of sf in the Example below. Code: Sub Globals Dim sf As StringFunctions sf.Initialize End Sub StringFunctions Version 1.05 AsciiCodes Displays a MessageBox with all Characters and their ASCII codes. AddSpaces (HowMany As Int) As String Returns a string of spaces. The number returned is set by HowMany. At (YourString As String, SearchFor As String)) Returns the position of the SearchFor within YourString. CurrentWeek (MyDate As String) As Int Returns the number of the current week, 1-52 from the date passed to MyDate. DayOfMonth (MyDate As ) As Int Returns the day of the month like 1-31, from the date passed to MyDate. Decrypt (YourText As String) As String Converts an encrypted string of text to readable format, no key is needed. Empty (StringText As String) As Boolean Test to see if the string is empty and returns True if it is, otherwise returns False. Encrypt (YourText As String) As String Converts a string of text to simple encryption, no Key is needed. EraseData This will erase all data saved with the SaveData function stored in the temporary vault. FileExist (PathAndFileName As String) As Boolean Returns True if the filename passed does exist, otherwise returns False. Be sure to include the path like: If FileExist("/mnt/sdcard/mydata.dat") Then MsgBox("Yes", "The Answer") GetData (Key As Object) As Object Gets data from the temporary vault. EditText1.Text = SF.GetData("EnteredName") The Key is case sensitive. InString (YourString As String, SearchFor As String)) Returns the position of the SearchFor within YourString. IsEmpty (StringText As String) As Boolean Test to see if the string is empty and returns True if it is, otherwise returns False. Left (StringText As String, Length As Long) As String Returns the Left portion of a string with the number of characters passed in Length. Len (StringText As String) As Long Returns the length of the string. ListToString (YourList As List, Sorted As Boolean, Ascending As Boolean) As String Converts a List object to a String. ListToStringArray (YourList As List, Sorted As Boolean, Ascending As Boolean) As String() Converts a List object to a String Array. Lower (StringText As String) As String Returns the string converted to Lowercase characters. Ltrim (StringText As String) As String Returns a new string with the leading spaces removed. MB (Message As String) Same as MsgBox but only needs one parameter. Mid (StringText As String, Start As Int, Length As Int) As String Returns the a new String for how ever many characters passed in Length from a starting position passed in Start. Example: Mid("This is a long line of text", 5, 2) In this example the function will Return: "is" MidExtract (StringText As String, Start As String, EndAt As String) As String Used to extract text from a string between to other blocks of text. Ans = MidExtract("Dr. Jim Joe Brown", "Jim", "Brown") 'Returns: Joe Ans = MidExtract("Dr. Jim [Joe] Brown", "[", "]") 'Returns: Joe MidS (StringText As String, StartAt As Int) As String Works like the Mid$ function in Visual Basic. Month (MyDate As String) As Int Returns the number of the current month 1-12 as Int type, from the date passed to MyDate. MonthName (MyDate As String) As String Returns the Name the current month as a String like January, etc., from the date passed to MyDate. NewDate (DatePassed As String, HowManyDays As Int) As String Returns a new date adding or subtracting HowManyDays. HowManyDays can be positive or negative numbers. NumOfDaysBetween (CurrentDate As String, OtherDate As String) As Int Returns the numbers of days passed between the two dates passed. Pad (Text As String, PadWith As String, Length As Int, Post As Boolean) As String Used to pad a string with a selected character. If Post = True the padding will follow any text in the string, if Post = False, the padding will be before the text. Length is the total length for the padded string. PadWith is the selected character to use for the padding. SF.Pad("Jimmy Joe", "*", 20, True) 'Returns "Jimmy Joe***********" Proper (StringText As String) As String Returns the string in proper format. Example: MyText = "jim joe brown" MyText = SF.Proper(Mytext) This function will return: "Jim Joe Brown" Replicate (mChar As String, Times As Int) As String Repeats any character passed, a selected number of Times. Right (StringText As String, Length As Long) As String Returns the Right portion of a string with the number of characters passed in Length. RndChrGen (StringLength As Int, CharacterType As Int) As String Returns a string of ramdom characters with a length specified by StringLength. CharacterType tells the function what type of characters to return. CharacterType = 0 for Upper and Lower case CharacterType = 1 for Upper case only CharacterType = 2 for Lower case only Rtrim (StringText As String) As String Returns a new string with the trailing spaces removed. SaveData (Key As Object, Data As Object) Save data passed in a temporary file. SF.SaveData("ScreenTitle", MyVar) or SF.SaveData("EnteredName", EditText1.Text) ScrInfo ( As Pect) As Int Returns information about the devices screen. You can pass these parameters: Pass "W" for Width Pass "H" for Height Pass "S" for Scale Pass "D" for DPI Call like: SF.ScrInfo("W") SearchDate (Date1 As String, Date2 As String, DateRange As Int) As Boolean Returns True if the Date1 and the Date2 are within x Days(DateRange) of each other. Pass the dates as Strings. Example: SearchDate("03/01/2013", "02/15/2013", 30) Split (CurrentString As String, Split_At_Delimiter As String) As List Returns a LIST of items from the string split at the Delimiter. EXAMPLE: Dim ANS As List ANS = SF.Split("This is a test string.", " ") SplitGetWord (CurrentString As String, Split_At_Delimiter As String, GetElement As Int) As String Returns just the one element selected with GetElement from the string. EXAMPLE: ANS = SF.SplitGetWord("This is a test string.", " ", 2) In this example the function will Return: "is" StrArraySort (StringArray() As String, Ascending As Boolean) As String() Used to sort a String Array. Sort will be in Ascending order if Ascending = True. StringArrayToList (StringArray() As String, Sorted As Boolean, Ascending As Boolean) As List Converts a String Array to a List object. StringToList (StringText As String, Sorted As Boolean, Ascending As Boolean) As List Convert a String to a List object. This will split the string between words. Stuff (CurrentText As String, InsertInString As String, RemoveFromString As String) As String Used to replace text in a string with new text. Example: MyText = "I will tell you that joe is a good friend!" MyText = SF.Stuff(MyText, "Joe Brown", "joe") This function will return: "I will tell you that Joe Brown is a good friend!" Today () As String Returns the devices date. Trim (Text As String) As String Returns a new string with leading and trailing spaces removed. Upper (StringText As String) As String Returns the string converted to Uppercase characters. Val (StringText As String) As Double Returns the numerical value of a string. If the string contains now value it returns 0. ValidDate (ChkDate As ) As Boolean Returns True if the date passed is a Valid date. WeekDay (MyDate As String) As String Returns the number of the day of the week 1-7 as a String, from the date passed to MyDate. WeekName (MyDate As String) As String Returns the name of the day of the week like Sunday, Monday, etc., from the date passed to MyDate. Year (MyDate As String) As String Returns the year of the date passed in MyDate. Example: SF.Year("01/01/2013") returns "2013" getSDCardPath () As String Returns external/physical SD Card directory. This function may not return the correct store on an Android OS above 4.1. This is due to changes made to the OS system in the newer versions. Returns "", if the store can not be read. iif (Value1 As String, Value2 As String, Value3 As String) As String This is a single line if conditional test. If Value1 is true, Value2 is returned, otherwise Value3 will be returned. Works with strings and booleans. Example: MsgBox(iif("Bob"="Jim", "They are the same", "They are not the same"), "The Answer") or MyBoolean = iif(FirstTime = True, StartMyService = True, StartMyService = False)
T Thomas Wong Member Licensed User Longtime User Jun 17, 2013 #81 Hi, Any idea how to use the Encrypt and Decrypt function in StringFunctions library? How can I specify the salt/key for it? I tried to search for documentation for this library but I can't find anything. Regards, Thomas
Hi, Any idea how to use the Encrypt and Decrypt function in StringFunctions library? How can I specify the salt/key for it? I tried to search for documentation for this library but I can't find anything. Regards, Thomas
ValDog Active Member Licensed User Longtime User Jun 19, 2013 #82 Margret, can you please check the DayOfMonth method? It does not seem to be working correctly. DayOfMonth("6/17/2013"), for instance, returns a 6 ??
Margret, can you please check the DayOfMonth method? It does not seem to be working correctly. DayOfMonth("6/17/2013"), for instance, returns a 6 ??
margret Well-Known Member Licensed User Longtime User Jun 24, 2013 #83 Sorry, please try this new version and let me know. If all is fine I will update post #1 with this version. ValDog said: Margret, can you please check the DayOfMonth method? It does not seem to be working correctly. DayOfMonth("6/17/2013"), for instance, returns a 6 ?? Click to expand... Attachments StrFunc_1.02.zip StrFunc_1.02.zip 7.4 KB · Views: 659
Sorry, please try this new version and let me know. If all is fine I will update post #1 with this version. ValDog said: Margret, can you please check the DayOfMonth method? It does not seem to be working correctly. DayOfMonth("6/17/2013"), for instance, returns a 6 ?? Click to expand...
ValDog Active Member Licensed User Longtime User Jun 24, 2013 #84 Margret, Thanks - seems to be OK now...
PhilN Member Licensed User Longtime User Jul 11, 2013 #85 You're a star! Thank you Margret for the StringsFunction library. It makes life soooooo much easier. Did I say your a star? I forget... You're a star!
You're a star! Thank you Margret for the StringsFunction library. It makes life soooooo much easier. Did I say your a star? I forget... You're a star!
PhilipBrown Active Member Licensed User Longtime User Aug 27, 2013 #86 A StringIndexOutOfBoundsException will be raised if there are too few characters in the function Mid, for example Log(sf.Mid("This is a long line of text", 1, 400))
A StringIndexOutOfBoundsException will be raised if there are too few characters in the function Mid, for example Log(sf.Mid("This is a long line of text", 1, 400))
rbsoft Active Member Licensed User Longtime User Aug 27, 2013 #87 This should solve the problem: Code: Sub Mid(TEXT As String, Start As Int, Length As Int) As String If TEXT.Length > 0 Then If Start + Length <= TEXT.Length Then Return TEXT.SubString2(Start-1, Start + Length - 1) End If End If End Sub Rolf
This should solve the problem: Code: Sub Mid(TEXT As String, Start As Int, Length As Int) As String If TEXT.Length > 0 Then If Start + Length <= TEXT.Length Then Return TEXT.SubString2(Start-1, Start + Length - 1) End If End If End Sub Rolf
PhilipBrown Active Member Licensed User Longtime User Aug 27, 2013 #88 Personally, I would have expected the library itself to take care of this...
rbsoft Active Member Licensed User Longtime User Aug 27, 2013 #89 That's what I meant, it to be changed in the library. This is the extra code I inserted into the library code. Code: If Start + Length <= TEXT.Length Then ... End If I think Margret will take care of that, maybe she has some additional thoughts. Rolf
That's what I meant, it to be changed in the library. This is the extra code I inserted into the library code. Code: If Start + Length <= TEXT.Length Then ... End If I think Margret will take care of that, maybe she has some additional thoughts. Rolf
margret Well-Known Member Licensed User Longtime User Aug 28, 2013 #90 Hello All, I will add this. I just didn't think about it as the functions were pulled together but it's a good idea!
Hello All, I will add this. I just didn't think about it as the functions were pulled together but it's a good idea!
margret Well-Known Member Licensed User Longtime User Aug 28, 2013 #91 The library has been updated to version 1.03. It is attached to post #1. I just changed the code but did not test this. Please let me know if you have any other issues.
The library has been updated to version 1.03. It is attached to post #1. I just changed the code but did not test this. Please let me know if you have any other issues.
C ComposerB4A Member Licensed User Longtime User Sep 2, 2013 #92 Hello, Is one question, i load que librery and set one code: Sub Activity_Create(FirstTime As Boolean) Msgbox(len("abc"),"") End Sub but not recognizes the word "len" ¿anyone know what the error is? Attachments NoFuncionaLaLibreria.jpg 85.2 KB · Views: 589
Hello, Is one question, i load que librery and set one code: Sub Activity_Create(FirstTime As Boolean) Msgbox(len("abc"),"") End Sub but not recognizes the word "len" ¿anyone know what the error is?
NJDude Expert Licensed User Longtime User Sep 2, 2013 #93 You have to initialize the library, like this for example: Code: Dim sf As StringFunctions ... Msgbox(sf.Len("abc"), "") A separate note, why are you referencing ALL the libraries? you just need to reference the ones you will need in your project.
You have to initialize the library, like this for example: Code: Dim sf As StringFunctions ... Msgbox(sf.Len("abc"), "") A separate note, why are you referencing ALL the libraries? you just need to reference the ones you will need in your project.
ferdztech Member Licensed User Longtime User Sep 12, 2013 #95 hi @margret i try to use the mid string function how could i get the rest of the string without defining its length. for example the content of mystring is dynamic not constant mystring="the quick brown fox jump over the head of the lazy dog" In your example: Mid (StringText As String, Start As Int, Length As Int) As String Returns the a new String for how ever many characters passed in Length from a starting position passed in Start. Example: Mid(This is a long line of text, 5, 2) In this example the function will Return: "is" in vb varstring=mid$("This is a long line of text",5) In this example the function will Return: "is a long line of text"
hi @margret i try to use the mid string function how could i get the rest of the string without defining its length. for example the content of mystring is dynamic not constant mystring="the quick brown fox jump over the head of the lazy dog" In your example: Mid (StringText As String, Start As Int, Length As Int) As String Returns the a new String for how ever many characters passed in Length from a starting position passed in Start. Example: Mid(This is a long line of text, 5, 2) In this example the function will Return: "is" in vb varstring=mid$("This is a long line of text",5) In this example the function will Return: "is a long line of text"
margret Well-Known Member Licensed User Longtime User Sep 12, 2013 #96 in vb varstring=mid$("This is a long line of text",5) In this example the function will Return: "is a long line of text" Click to expand... In the next update I will add a new function that will replicate this. Last edited: Sep 12, 2013
in vb varstring=mid$("This is a long line of text",5) In this example the function will Return: "is a long line of text" Click to expand... In the next update I will add a new function that will replicate this.
ferdztech Member Licensed User Longtime User Sep 13, 2013 #97 margret said: In the next update I will add a new function that will replicate this. Click to expand... That's cool, One more suggestion. Is it possible to make a function like: InStrRev as in VB in VB for example: mystring="the quick brown fox jump over the head of the lazy dog" varstring= Mid$(mystring, 1, InStrRev(mystring, "fox")) this, will return "The quick brown f" In B4a: I tried this way to extract string, which use two method substring2 and substring varstring=mystring.SubString2(0,mystring.IndexOf("fox")) varstring=varstring.SubString(varstring.IndexOf("the")) Maybe its better ? to use your new replicate mid function and the new replicate of instrRev function to make it simple. Thanks Again and More Power!
margret said: In the next update I will add a new function that will replicate this. Click to expand... That's cool, One more suggestion. Is it possible to make a function like: InStrRev as in VB in VB for example: mystring="the quick brown fox jump over the head of the lazy dog" varstring= Mid$(mystring, 1, InStrRev(mystring, "fox")) this, will return "The quick brown f" In B4a: I tried this way to extract string, which use two method substring2 and substring varstring=mystring.SubString2(0,mystring.IndexOf("fox")) varstring=varstring.SubString(varstring.IndexOf("the")) Maybe its better ? to use your new replicate mid function and the new replicate of instrRev function to make it simple. Thanks Again and More Power!
margret Well-Known Member Licensed User Longtime User Sep 13, 2013 #98 I can add a command to do this too but you can do it now like this: Code: Dim MyString, VarString As String MyString = "the quick brown fox jump over the head of the lazy dog" VarString = sf.Left(MyString, sf.At(MyString, "fox")) Log(VarString)
I can add a command to do this too but you can do it now like this: Code: Dim MyString, VarString As String MyString = "the quick brown fox jump over the head of the lazy dog" VarString = sf.Left(MyString, sf.At(MyString, "fox")) Log(VarString)
ttsolution Member Licensed User Longtime User Sep 19, 2013 #99 Dear all, I have below error while compling. Please help. Many thanks Jonh sf.Initialize javac 1.7.0_07 src\b4a\example\main.java:311: error: cannot access ImplB4AClass mostCurrent._sf._vvv1(processBA); ^ class file for anywheresoftware.b4a.B4AClass$ImplB4AClass not found 1 error
Dear all, I have below error while compling. Please help. Many thanks Jonh sf.Initialize javac 1.7.0_07 src\b4a\example\main.java:311: error: cannot access ImplB4AClass mostCurrent._sf._vvv1(processBA); ^ class file for anywheresoftware.b4a.B4AClass$ImplB4AClass not found 1 error
R ralphie911 Member Licensed User Longtime User Sep 19, 2013 #100 Margret, thanks sop much for all your hard work. I do think I found a little bug in your MID function. While parsing bytes out of a hex string. I had to add an extra character for the last "byte" to be pulled without causing an OutOfBounds exception. here is a code snippet: Sub CRC16() Dim j, nC, CRC AsInt Dim c, hextxt AsString hextxt = "0103000A0003 " CRC = 0xFFFF For nC = 1Tosf.Len(hextxt)-1Step2 j = Bit.ParseInt(sf.Mid(hextxt, nC, 2),16) 'extract hex byte CRC = Bit.Xor(CRC, j) Next
Margret, thanks sop much for all your hard work. I do think I found a little bug in your MID function. While parsing bytes out of a hex string. I had to add an extra character for the last "byte" to be pulled without causing an OutOfBounds exception. here is a code snippet: Sub CRC16() Dim j, nC, CRC AsInt Dim c, hextxt AsString hextxt = "0103000A0003 " CRC = 0xFFFF For nC = 1Tosf.Len(hextxt)-1Step2 j = Bit.ParseInt(sf.Mid(hextxt, nC, 2),16) 'extract hex byte CRC = Bit.Xor(CRC, j) Next