Revision history for KeyPgZstring


Revision [22263]

Last edited on 2018-04-09 08:18:29 by fxm [Added in description: auto compiler conversion between any string argument and 'Zstring Ptr' parameter when calling procedure]
Additions:
Any intrinsic string functions like ##[[KeyPgLeft|Left]]## will work with ##**Zstring**##'s too, plus any string operator.
This type is provided for easy interfacing with C libraries and to also replace the fixed-length strings, that can't be managed through pointers.
Any string type argument may be directly passed to a procedure referring to a parameter declared as ##**Zstring** [[KeyPgPtr|ptr]]##. The compiler performs itself an automatic conversion (without warning message) between any string type argument and the ##**Zstring** [[KeyPgPtr|ptr]]## type parameter.
Deletions:
This type is provided for easy interfacing with C libraries and to also replace the fixed-length strings, that can't be managed through pointers. Any intrinsic string functions like ##[[KeyPgLeft|Left]]## will work with ##**Zstring**##'s too, plus any string operator.


Revision [22036]

Edited on 2017-12-09 00:28:11 by fxm [Added note on dereferencing a 'zstring ptr' pointer as operand of the '=' operator]
Additions:
**Note :** When any operand of the '##=##' operator (assignment or equal) consists in dereferencing a '##Zstring Ptr##' pointer ('##pz##'), this can give a '##Zstring##' string or a '##Ubyte##' character, depending on the other operand. If the other operand is numeric, so the dereferenced '##Zstring Ptr##' pointer ('##*pz##') will be treated as a '##Ubyte##' reference to the one character pointed. If a '##Zstring##' pointer indexing '##[]##' operator is used as dereferencing syntax ('##pz[n]##'), it is basically a short-cut version of the '##String##' indexing '##[]##' operator ('##(*pz)[n]##').


Revision [21197]

Edited on 2016-03-13 12:03:11 by fxm [Formatting]

No Differences

Revision [20616]

Edited on 2016-02-10 16:11:27 by DkLwikki [Update link format]
Additions:
[[KeyPgDim|dim]] //variable// [[KeyPgAs|as]] **Zstring** * //size//
[[KeyPgDim|dim]] //variable// [[KeyPgAs|as]] **Zstring** [[KeyPgPtr|ptr]]
A ##**Zstring** [[KeyPgPtr|ptr]]## can point to a standard ##**Zstring**##, also can be used to implement an "user-managed" ##**Zstring**##, in this case ##[[KeyPgAllocate|Allocate]]##/##[[KeyPgReallocate|Reallocate]]##/##[[KeyPgDeallocate|Deallocate]]## must be used to size-resize-dispose it and is up to the user to avoid overflows .
The end of the string is marked by a null character (##0## ASCII). This is automatically added by the ""FreeBASIC"" string handling functions. A null character will be appended when the string is created, and the length will be calculated by scanning the string for the first null character. A null character (e.g. ##[[KeyPgChr|Chr]](0)##) may never be contained in the text of a ##**Zstring**## or the rest of the string will be truncated.
In a ##**Zstring**##, ##[[KeyPgLen|Len]]## returns the size of the contained string and ##[[KeyPgSizeof|Sizeof]]## returns the space allocated to the ##**Zstring**##. ##[[KeyPgSizeof|Sizeof]]## only works if the size is known by the compiler, i.e. a fixed-size ##**Zstring**## variable is passed directly, not as a dereferenced pointer or a ##[[KeyPgByref|Byref]]## function argument.
This type is provided for easy interfacing with C libraries and to also replace the fixed-length strings, that can't be managed through pointers. Any intrinsic string functions like ##[[KeyPgLeft|Left]]## will work with ##**Zstring**##'s too, plus any string operator.
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Zstring""**##.
- ##[[KeyPgString|String]]##
- ##[[KeyPgWstring|Wstring]]##
Deletions:
[[KeyPgDim dim]] //variable// [[KeyPgAs as]] **Zstring** * //size//
[[KeyPgDim dim]] //variable// [[KeyPgAs as]] **Zstring** [[KeyPgPtr ptr]]
A ##**Zstring** [[KeyPgPtr ptr]]## can point to a standard ##**Zstring**##, also can be used to implement an "user-managed" ##**Zstring**##, in this case ##[[KeyPgAllocate Allocate]]##/##[[KeyPgReallocate Reallocate]]##/##[[KeyPgDeallocate Deallocate]]## must be used to size-resize-dispose it and is up to the user to avoid overflows .
The end of the string is marked by a null character (##0## ASCII). This is automatically added by the ""FreeBASIC"" string handling functions. A null character will be appended when the string is created, and the length will be calculated by scanning the string for the first null character. A null character (e.g. ##[[KeyPgChr Chr]](0)##) may never be contained in the text of a ##**Zstring**## or the rest of the string will be truncated.
In a ##**Zstring**##, ##[[KeyPgLen Len]]## returns the size of the contained string and ##[[KeyPgSizeof Sizeof]]## returns the space allocated to the ##**Zstring**##. ##[[KeyPgSizeof Sizeof]]## only works if the size is known by the compiler, i.e. a fixed-size ##**Zstring**## variable is passed directly, not as a dereferenced pointer or a ##[[KeyPgByref Byref]]## function argument.
This type is provided for easy interfacing with C libraries and to also replace the fixed-length strings, that can't be managed through pointers. Any intrinsic string functions like ##[[KeyPgLeft Left]]## will work with ##**Zstring**##'s too, plus any string operator.
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Zstring""**##.
- ##[[KeyPgString String]]##
- ##[[KeyPgWstring Wstring]]##


Revision [16921]

Edited on 2013-08-29 14:28:48 by FxMwikki [last code line suppressed: sizeof( *z/wstringptr ) returns now sizeof( z/wstring ) instead of 0]
Deletions:
print sizeof(*str2) 'returns 0, because a dereferenced pointer is passed and not a variable


Revision [16178]

Edited on 2012-05-22 13:02:53 by FxMwikki [Examples update]
Additions:
print sizeof(*str2) 'returns 0, because a dereferenced pointer is passed and not a variable
Deletions:
print sizeof(*str2) 'returns 0, because a dereferenced pointer is passed and not a reference


Revision [16177]

Edited on 2012-05-22 04:06:49 by FxMwikki [Examples update]
Additions:
dim as zstring * 13 str1 => "hello, world"
print len(str1) 'returns 12, the size of the string it contains
print sizeof(str1) 'returns 13, the size of the variable
str2 = allocate( 13 )
print len(*str2) 'returns 12, the size of the string it contains
print sizeof(*str2) 'returns 0, because a dereferenced pointer is passed and not a reference
Deletions:
dim as zstring * 14 str1 => "hello, world"
print len(str1) 'returns 12, the size of the string it contains
print sizeof(str1) 'returns 14, the size of the variable
str2 = allocate( 14 )
print len(*str2) 'returns 12, the size of the string it contains
print sizeof(*str2) 'returns len(zstring), the size of the variable


Revision [15463]

Edited on 2011-10-25 12:05:25 by CountingPine [Formatting, a couple of size-related clarifications]
Additions:
A ##**Zstring**## is a C-style fixed-size array of chars. It has no descriptor so its length is calculated faster to pass it as an argument to functions. When the variable has a fixed ##//size//##, ""FreeBASIC"" avoids any overflow that could occur on assignment, by truncating the contents to a length of ##//size// - 1##.
A ##**Zstring** [[KeyPgPtr ptr]]## can point to a standard ##**Zstring**##, also can be used to implement an "user-managed" ##**Zstring**##, in this case ##[[KeyPgAllocate Allocate]]##/##[[KeyPgReallocate Reallocate]]##/##[[KeyPgDeallocate Deallocate]]## must be used to size-resize-dispose it and is up to the user to avoid overflows .
The end of the string is marked by a null character (##0## ASCII). This is automatically added by the ""FreeBASIC"" string handling functions. A null character will be appended when the string is created, and the length will be calculated by scanning the string for the first null character. A null character (e.g. ##[[KeyPgChr Chr]](0)##) may never be contained in the text of a ##**Zstring**## or the rest of the string will be truncated.
In a ##**Zstring**##, ##[[KeyPgLen Len]]## returns the size of the contained string and ##[[KeyPgSizeof Sizeof]]## returns the space allocated to the ##**Zstring**##. ##[[KeyPgSizeof Sizeof]]## only works if the size is known by the compiler, i.e. a fixed-size ##**Zstring**## variable is passed directly, not as a dereferenced pointer or a ##[[KeyPgByref Byref]]## function argument.
Deletions:
A ##**Zstring**## is a C-style fixed-size array of chars. It has no descriptor so it's faster to pass it as an argument to functions. FreeBASIC avoids any overflow that could occur, by truncating the contents.
A ##**Zstring**## [[KeyPgPtr ptr]] can point to a standard ##**Zstring**##, also can be used to implement an "user-managed" ##**Zstring**##, in this case ##[[KeyPgAllocate Allocate]]##/##[[KeyPgReallocate Reallocate]]##/##[[KeyPgDeallocate Deallocate]]## must be used to size-resize-dispose it and is up to the user to avoid overflows .
The end of the string is marked by a character 0 ASCII, this is automatically managed by the FreeBASIC string handling functions. A character 0 ASCII must never enter in the text of a ##**Zstring**## or it will be truncated, as no descriptor exists .
In a ##**Zstring**##, ##[[KeyPgLen Len]]## returns the size of the contained string and ##[[KeyPgSizeof Sizeof]]## returns the space allocated to the ##**Zstring**##.


Revision [14474]

Edited on 2009-08-29 21:57:52 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [13182]

The oldest known version of this page was created on 2008-04-24 15:44:32 by JeffMarshall [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode