BASIC String Functions: Left, Right, and Mid?

mikroC, mikroBasic and mikroPascal PRO for Microchip’s (formerly Atmel) 8-bit AVR MCUs
Post Reply
Author
Message
jimMikroAVR
Posts: 3
Joined: 27 Feb 2010 19:56

BASIC String Functions: Left, Right, and Mid?

#1 Post by jimMikroAVR » 21 Dec 2021 02:31

Does AVR PRO BASIC support the standard string functions like Left, Right, and Mid? Or is there another string function available?

Thanks!

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: BASIC String Functions: Left, Right, and Mid?

#2 Post by Thomas.Pahl@t-online.de » 21 Dec 2021 11:59

you will not find these functions in mikro basic. mikro basic is a little bit C-ish. :D There is no print, no input, no inkey$ ...

But there are other functions instead.
copy from help:

str_cut_left
Prototype sub procedure str_cut_left(dim byref S1 as string, dim n as word)

Returns Nothing

Description This routine crops the input string S1 to the left starting from the position n.

Example string_ = "mikroE"

str_cut_left(string_, 2) ' string will be "kroE"



str_cut_right
Prototype sub procedure str_cut_right(dim byref S1 as string, dim n as word)

Returns Nothing

Description This routine crops the input string S1 to the right starting from the position n.

Example string_ = "mikroE"

str_cut_right(string_, 3) ' string will be "mik"



str_split
Prototype sub procedure str_split(dim byref S1, S2 as string, dim n as word)

Returns Nothing

Description This routine splits the input string S1 into two strings, S1 and S2, starting from the position n. If the string S2 is not long enough to hold the splitting part, behavior is undefined.

Example string1 = "MikroElektronika"

str_split(string1, string2, 5) ' after the split, string1 will be "Mikro" and string2 "Elektronika"

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: BASIC String Functions: Left, Right, and Mid?

#3 Post by Thomas.Pahl@t-online.de » 21 Dec 2021 12:08

Edit:
sorry, i am just working with mikrobasic for arm - in mikro basic for avr these functions are not available.
you have to build them yourself!
in mikrobasic strings are arrays of one dimension with a null-character at the end. you can easily build these functions.

Post Reply

Return to “AVR PRO Compilers”