1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-26 07:25:53 +00:00
QB64-PE/internal/help/MID$.txt
SMcNeill 6e01fc8dce Altered string compare routines (<,<=,>,>=) so they don't give false results with CHR$(0).
Added new _STRCMP and _STRICMP commands for quick string comparisons.
Cleaned up QB64 to finish removing the QUI (quick user insert) code and folders.
Altered UCASE and LCASE routines to be faster in some situations for us.
2014-09-22 08:19:03 -04:00

42 lines
1.6 KiB
Plaintext

The '''MID$''' function returns a portion of a [[STRING]]'s value from any position inside a string.
{{PageSyntax}}
:: MID$(''stringvalue$'', ''startposition%''[, ''bytes%''])
''[[Parameters]]:''
* ''stringvalue'' can be any literal or variable [[STRING]] value having a length. See [[LEN]].
* ''startposition'' designates the non-zero position of the first character to be returned by the function.
* ''bytes'' (optional) tells the function how many characters to return including the first character when it is used.
''Usage:''
* When the ''bytes'' value is not used the function returns the remainder of the string from the starting character position.
* Number of character ''bytes'' should be within the string's [[LEN|length]] from the start position, but will only return the string's remainder when exceeded.
* If the ''bytes'' value is 0 or the ''start position'' is 0 or greater than the [[LEN|length]] of the string, nothing is returned (no error).
* In QBasic the ''start position'' cannot be zero(0) or an [[ERROR Codes|Illegal function call error]] will occur.
''Example:'' Getting the hour and minutes from [[TIME$]]
{{CodeStart}} '' ''
{{Cl|PRINT}} {{Cl|TIME$}}
hour$ = {{Cl|LEFT$}}({{Cl|TIME$}}, 2)
minutes$ = {{Cl|MID$}}({{Cl|TIME$}}, 4, 2) ' skip hours and the colon (3 characters)
{{Cl|PRINT}} &quot;hour = &quot;; hour$; &quot;: minutes = &quot;; minutes$ '' ''
{{CodeEnd}}
{{OutputStart}}
11:23:30
hour = 11: minutes = 23
{{OutputEnd}}
''See also:''
* [[MID$ (statement)]], [[LEFT$]], [[RIGHT$]]
* [[LTRIM$]], [[RTRIM$]], [[INSTR]], [[LEN]]
{{PageNavigation}}