Revision history for KeyPgCvi


Revision [21774]

Last edited on 2017-07-01 08:21:54 by CountingPine [Explain more about the INTEGER size dependency]
Additions:
Converts a floating-point number or string to an integer variable using a binary copy
32-bit:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Cvi** ( [[KeyPgByval|byval]] //f// [[KeyPgAs|as]] [[KeyPgSingle|single]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]]
64-bit:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Cvi** ( [[KeyPgByval|byval]] //f// [[KeyPgAs|as]] [[KeyPgDouble|double]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]]
##//f//##
A floating-point number with a binary copy of an integer variable stored in it. Its precision (##[[KeyPgSingle|Single]]## or ##[[KeyPgDouble|Double]]##) depends on the size of ##[[KeyPgInteger|Integer]]## on the current platform
Returns an integer value using the binary data contained in a floating-point value, or a ##[[KeyPgString|String]]##. A value of zero (##0##) is returned if the string contains fewer characters than the size of the return type.
##**Cvi**## can be used to convert strings created with ##[[KeyPgMki|Mki]]##.
This function can also be used to convert ##[[KeyPgInteger|Integer]]##-sized values from a memory or file buffer without the need for a ##[[KeyPgType|Type]]## structure. However, just as with the type structure, special care should be taken when using ##**Cvi**## to convert strings that have been read from a buffer.
##**Cvi**##'s behaviour changes depending on the size of the ##[[KeyPgInteger|Integer]]## data type on the current platform.
- For 16-bit ##[[KeyPgInteger|Integer]]## (//[[CompilerOptlang|-lang qb]]//), a 16-bit value is returned, and no floating-point types are accepted.
- For 32-bit ##[[KeyPgInteger|Integer]]##, a 32-bit value is returned, and numeric arguments are interpreted as ##[[KeyPgSingle|Single]]## precision values.
- For 64-bit ##[[KeyPgInteger|Integer]]##, a 64-bit value is returned, and numeric arguments are interpreted as ##[[KeyPgDouble|Double]]## precision values.
Deletions:
Converts a single-precision floating-point number or string to an integer variable using a binary copy
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Cvi** ( [[KeyPgByval|byval]] //sng// [[KeyPgAs|as]] [[KeyPgSingle|single]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]]
##//sng//##
A ##[[KeyPgSingle|Single]]## floating-point number with a binary copy of an integer variable stored in it.
Returns an integer value using the binary data contained in a ##[[KeyPgSingle|Single]]##, or a ##[[KeyPgString|String]]##. A value of zero (##0##) is returned if the string contains fewer characters than the size of the return type.
##**Cvi**## is used to convert strings created with ##[[KeyPgMki|Mki]]##.
This function can also be used to convert 32-bit integer values from a memory or file buffer without the need for a ##[[KeyPgType|Type]]## structure. However, just as with the type structure, special care should be taken when using ##**Cvi**## to convert strings that have been read from a buffer.


Revision [20873]

Edited on 2016-03-12 16:15:27 by fxm [Formatting]
Additions:




Revision [20120]

Edited on 2016-02-10 15:56:30 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Cvi** ( [[KeyPgByval|byval]] //sng// [[KeyPgAs|as]] [[KeyPgSingle|single]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Cvi** ( [[KeyPgByref|byref]] //str// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Cvi**<//bits>// ( //expr// [[KeyPgAs|as]] [[DataType]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]]<//bits//>
A ##[[KeyPgSingle|Single]]## floating-point number with a binary copy of an integer variable stored in it.
A ##[[KeyPgString|String]]## with a binary copy of an integer variable stored in it.
An expression that will be copied into an ##[[KeyPgInteger|Integer]]<//bits//>##.
An ##[[KeyPgInteger|Integer]]## or ##[[KeyPgInteger|Integer]]<//bits//>## variable containing a binary copy of the input expression.
Returns an integer value using the binary data contained in a ##[[KeyPgSingle|Single]]##, or a ##[[KeyPgString|String]]##. A value of zero (##0##) is returned if the string contains fewer characters than the size of the return type.
##**Cvi**## is used to convert strings created with ##[[KeyPgMki|Mki]]##.
This function can also be used to convert 32-bit integer values from a memory or file buffer without the need for a ##[[KeyPgType|Type]]## structure. However, just as with the type structure, special care should be taken when using ##**Cvi**## to convert strings that have been read from a buffer.
##**Cvi**## supports an optional ##<//bits//>## parameter before the argument. If ##//bits//## is ##16##, ##[[KeyPgCvshort|Cvshort]]## will be called instead; if ##//bits//## is ##32##, ##[[KeyPgCvl|Cvl]]## will be called; if ##//bits//## is ##64##, ##[[KeyPgCvlongint|Cvlongint]]## will be called. The return type and accepted argument types will depend on which function is called. See each function's page for more information.
- In the //[[CompilerOptlang|-lang qb]]// dialect, ##**Cvi**## expects a 2-byte string, since a QB integer is only 16 bits. Only the first two bytes of the string are used, even if the string happens to be longer than two bytes.
- In the //[[CompilerOptlang|-lang qb]]// dialect, ##**Cvi**## will not take a floating-point argument, since a QB integer is only 16 bits and there is no 16-bit floating-point data type. Instead, ##**Cvi**<32>##/##**Cvi**<64>## or ##[[KeyPgCvl|Cvl]]##/##[[KeyPgCvlongint|Cvlongint]]## may be used.
- ##[[KeyPgMki|Mki]]##
- ##[[KeyPgCvshort|Cvshort]]##
- ##[[KeyPgCvl|Cvl]]##
- ##[[KeyPgCvlongint|Cvlongint]]##
- ##[[KeyPgInteger|Integer]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByval byval]] //sng// [[KeyPgAs as]] [[KeyPgSingle single]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByref byref]] //str// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi**<//bits>// ( //expr// [[KeyPgAs as]] [[DataType]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]<//bits//>
A ##[[KeyPgSingle Single]]## floating-point number with a binary copy of an integer variable stored in it.
A ##[[KeyPgString String]]## with a binary copy of an integer variable stored in it.
An expression that will be copied into an ##[[KeyPgInteger Integer]]<//bits//>##.
An ##[[KeyPgInteger Integer]]## or ##[[KeyPgInteger Integer]]<//bits//>## variable containing a binary copy of the input expression.
Returns an integer value using the binary data contained in a ##[[KeyPgSingle Single]]##, or a ##[[KeyPgString String]]##. A value of zero (##0##) is returned if the string contains fewer characters than the size of the return type.
##**Cvi**## is used to convert strings created with ##[[KeyPgMki Mki]]##.
This function can also be used to convert 32-bit integer values from a memory or file buffer without the need for a ##[[KeyPgType Type]]## structure. However, just as with the type structure, special care should be taken when using ##**Cvi**## to convert strings that have been read from a buffer.
##**Cvi**## supports an optional ##<//bits//>## parameter before the argument. If ##//bits//## is ##16##, ##[[KeyPgCvshort Cvshort]]## will be called instead; if ##//bits//## is ##32##, ##[[KeyPgCvl Cvl]]## will be called; if ##//bits//## is ##64##, ##[[KeyPgCvlongint Cvlongint]]## will be called. The return type and accepted argument types will depend on which function is called. See each function's page for more information.
- In the //[[CompilerOptlang -lang qb]]// dialect, ##**Cvi**## expects a 2-byte string, since a QB integer is only 16 bits. Only the first two bytes of the string are used, even if the string happens to be longer than two bytes.
- In the //[[CompilerOptlang -lang qb]]// dialect, ##**Cvi**## will not take a floating-point argument, since a QB integer is only 16 bits and there is no 16-bit floating-point data type. Instead, ##**Cvi**<32>##/##**Cvi**<64>## or ##[[KeyPgCvl Cvl]]##/##[[KeyPgCvlongint Cvlongint]]## may be used.
- ##[[KeyPgMki Mki]]##
- ##[[KeyPgCvshort Cvshort]]##
- ##[[KeyPgCvl Cvl]]##
- ##[[KeyPgCvlongint Cvlongint]]##
- ##[[KeyPgInteger Integer]]##


Revision [16813]

Edited on 2013-05-19 23:24:31 by CountingPine [Minor fixup, fewer 32-bit assumptions]
Additions:
Converts a single-precision floating-point number or string to an integer variable using a binary copy
##**Cvi**## supports an optional ##<//bits//>## parameter before the argument. If ##//bits//## is ##16##, ##[[KeyPgCvshort Cvshort]]## will be called instead; if ##//bits//## is ##32##, ##[[KeyPgCvl Cvl]]## will be called; if ##//bits//## is ##64##, ##[[KeyPgCvlongint Cvlongint]]## will be called. The return type and accepted argument types will depend on which function is called. See each function's page for more information.
- In the //[[CompilerOptlang -lang qb]]// dialect, ##**Cvi**## will not take a floating-point argument, since a QB integer is only 16 bits and there is no 16-bit floating-point data type. Instead, ##**Cvi**<32>##/##**Cvi**<64>## or ##[[KeyPgCvl Cvl]]##/##[[KeyPgCvlongint Cvlongint]]## may be used.
Deletions:
Converts a single-precision floating-point number or four-byte string to an integer variable using a binary copy
##**Cvi**## supports an optional ##<//bits//>## parameter before the argument. If ##//bits//## is ##16##, ##[[KeyPgCvshort Cvshort]]## will be called instead; if ##//bits//## is ##32##, ##[[KeyPgCvl Cvl]]## will be called; if ##//bits//## is ##64##, ##[[KeyPgCvlongint]]## will be called. The return type and accepted argument types will depend on which function is called. See each function's page for more information.


Revision [16610]

Edited on 2013-02-27 00:20:26 by CountingPine [New feature: CVI<n>()]
Additions:
Converts a single-precision floating-point number or four-byte string to an integer variable using a binary copy
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi**<//bits>// ( //expr// [[KeyPgAs as]] [[DataType]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]<//bits//>
//result// = **Cvi**<//bits//>( //expr// )
A ##[[KeyPgString String]]## with a binary copy of an integer variable stored in it.
##//bits//##
Specifies a size of integer type to return. The types and sizes of ##//expr//## accepted will depend on the corresponding function called.
##//expr//##
An expression that will be copied into an ##[[KeyPgInteger Integer]]<//bits//>##.
An ##[[KeyPgInteger Integer]]## or ##[[KeyPgInteger Integer]]<//bits//>## variable containing a binary copy of the input expression.
Returns an integer value using the binary data contained in a ##[[KeyPgSingle Single]]##, or a ##[[KeyPgString String]]##. A value of zero (##0##) is returned if the string contains fewer characters than the size of the return type.
##**Cvi**## is used to convert strings created with ##[[KeyPgMki Mki]]##.
##**Cvi**## supports an optional ##<//bits//>## parameter before the argument. If ##//bits//## is ##16##, ##[[KeyPgCvshort Cvshort]]## will be called instead; if ##//bits//## is ##32##, ##[[KeyPgCvl Cvl]]## will be called; if ##//bits//## is ##64##, ##[[KeyPgCvlongint]]## will be called. The return type and accepted argument types will depend on which function is called. See each function's page for more information.
- In QB an error occurs if the string passed is fewer than two bytes in length.
- QB did not support a ##<//bits//>## parameter.
- ##[[KeyPgInteger Integer]]##
Deletions:
Converts a single-precision floating-point number or four-byte string to an integer variable
A ##[[KeyPgString String]]## at least four bytes in length with a binary copy of an integer variable stored in it.
An ##[[KeyPgInteger integer]]## variable to copy the binary copy of a integer to.
Returns a 32-bit ##[[KeyPgInteger Integer]]## value using the binary data contained in a ##[[KeyPgSingle Single]]##, or a ##[[KeyPgString String]]## of at least four bytes in length. A value of zero (##0##) is returned if the string is less than four bytes in length.
##**Cvi**## is used to convert 4-byte strings created with ##[[KeyPgMki Mki]]##.
- In QB an error occurs if the string passed is less than two bytes in length.


Revision [16546]

Edited on 2013-01-22 23:37:07 by CountingPine [Use function in example]
Additions:
s = "ABCD"
i = cvi(s)
Deletions:
i = &H44434241
s = mki(i)


Revision [16534]

Edited on 2013-01-22 15:42:42 by CountingPine [Add Single param; misc changes]
Additions:
Converts a single-precision floating-point number or four-byte string to an integer variable
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByval byval]] //sng// [[KeyPgAs as]] [[KeyPgSingle single]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
//result// = **Cvi**( //sng// )
##//sng//##
A ##[[KeyPgSingle Single]]## floating-point number with a binary copy of an integer variable stored in it.
A ##[[KeyPgString String]]## at least four bytes in length with a binary copy of an integer variable stored in it.
An ##[[KeyPgInteger integer]]## variable to copy the binary copy of a integer to.
Returns a 32-bit ##[[KeyPgInteger Integer]]## value using the binary data contained in a ##[[KeyPgSingle Single]]##, or a ##[[KeyPgString String]]## of at least four bytes in length. A value of zero (##0##) is returned if the string is less than four bytes in length.
##**Cvi**## is used to convert 4-byte strings created with ##[[KeyPgMki Mki]]##.
This function can also be used to convert 32-bit integer values from a memory or file buffer without the need for a ##[[KeyPgType Type]]## structure. However, just as with the type structure, special care should be taken when using ##**Cvi**## to convert strings that have been read from a buffer.
dim i as integer, s as string
i = &H44434241
s = mki(i)
print using "i = _&H&"; hex(i)
print using "s = ""&"""; s
- In the //[[CompilerOptlang -lang qb]]// dialect, ##**Cvi**## expects a 2-byte string, since a QB integer is only 16 bits. Only the first two bytes of the string are used, even if the string happens to be longer than two bytes.
- QB did not support floating-point arguments.
- ##[[KeyPgCvshort Cvshort]]##
- ##[[KeyPgCvl Cvl]]##
- ##[[KeyPgCvlongint Cvlongint]]##
Deletions:
Converts an four byte string to an integer variable
A [[KeyPgString string]] exactly four bytes in length with a binary copy of an integer variable stored in it.
An [[KeyPgInteger integer]] variable to copy the binary copy of a integer to.
Returns a 32 bit ##[[KeyPgInteger Integer]]## value using the binary data contained in a string that is **exactly** four bytes in length. An integer value of zero (0) is returned if the string is not exactly four bytes in length.
##**Cvi**## is used to convert 4-byte-strings created with ##[[KeyPgMki Mki]]##.
This function can also be used to convert 32 bit integer values from a memory or file buffer without the need for a ##[[KeyPgType ]]## structure. However, just as with the type structure, special care should be taken when using ##**Cvi**## to convert strings that have been read from a buffer. The ##[[KeyPgCvi Cvi]]## and ##[[KeyPgMki Mki]]## functions are processor dependent. That is, they will return different results depending on the endianness of the processor.
dim a as integer, b as string
a=4534
b=mki(a)
print a, cvi(b)
sleep
- In the //[[CompilerOptlang -lang qb]]// dialect, ##**Cvi**## expects a 2-byte-string, since a QB integer is only 16 bits. Only the first two bytes of the string are used, even if the string happens to be longer than two bytes.


Revision [13943]

Edited on 2008-11-30 07:37:57 by JeffMarshall [name case fixup]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByref byref]] //str// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByref byref]] //str// [[KeyPgAs as]] [[KeyPgConstqualifier const]] [[KeyPgString string]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [13911]

Edited on 2008-11-28 18:54:04 by LaananFisher [Fixed: const-correctness]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByref byref]] //str// [[KeyPgAs as]] [[KeyPgConstqualifier const]] [[KeyPgString string]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByref byref]] //str// [[KeyPgAs as]] [[KeyPgString string]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [12256]

The oldest known version of this page was created on 2008-01-18 14:09:09 by JeffMarshall [Fixed: const-correctness]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode