Автор | Сообщение |
|
| |
Пост N: 3275
Зарегистрирован: 17.05.05
|
|
Отправлено: 06.07.13 17:52. Заголовок: [ ] (string) Harbour
Смотрю в Xharbour есть такая фича а в Harbour похоже ни кто не перенес. [ ] (string) : Character operator (unary): retrieves a character from a string. Syntax <cString>[<nPos>] Arguments <cString> <cString> is a character string containing at least one character. <nPos> <nPos> is a numeric expression which indicates the ordinal position of the character to retrieve. Description The character retrieves a single character at position <nPos> from the string <cString>. The value for <nPos> mus be in the range of 1 to Len(<cString>). Note: if <nPos> is a negative value, the operator retrieves the character Abs(<nPos>) from the end of the the string. Examples // The example shows how to access and change characters in a string. // Two functiosn are programmed which convert a numeric value to/from // a string containing only "1" and "0". PROCEDURE Main LOCAL cStr cStr := "xHarbour" ? cStr[5] // result: b cStr[5] := "B" ? cStr // result: xHarBour cStr[-1] := "B" ? cStr // result: xHarBouB RETURN В этой связи вопрос. Есть строка вида Cstr:="11111000001001101010101" Нужно вытащить ну скажем 12 символ. На ум приходит только такой вариант substr(Cstr,12,1). Какие есть еще варианты ?
|
|
|
Ответов - 2
[только новые]
|
|
|
| |
Пост N: 899
Зарегистрирован: 11.06.10
|
|
Отправлено: 06.07.13 19:03. Заголовок: Dima пишет: Смотрю ..
Dima пишет: цитата: | Смотрю в Xharbour есть такая фича а в Harbour похоже ни кто не перенес. |
|
смотрим core\contrib\hbxpp\tests\opover.prg правда этот момент с индексом -1 где-то уже обсуждали Dima пишет:
|
|
|
|
| |
Пост N: 3276
Зарегистрирован: 17.05.05
|
|
Отправлено: 06.07.13 19:12. Заголовок: AlexMyr пишет: смот..
AlexMyr пишет: цитата: | смотрим core\contrib\hbxpp\tests\opover.prg |
| Сенкс
|
|
|
|