Normal behavior.counting_pine wrote:I've made a bug report at https://github.com/freebasic/fbc/issues/111 .
See the note I had already added to the ZSTRING page.
Normal behavior.counting_pine wrote:I've made a bug report at https://github.com/freebasic/fbc/issues/111 .
Code: Select all
Dim PasswordChange As Integer = *row
Code: Select all
Dim PasswordChange As Integer = *row[4]
As is, those obviously don't compile. But given sensible types, you'd expect (*MyZStringPtr)[idx1] to index a zstring and return a character.MrSwiss wrote:get one string from array: (*ZString Ptr)[idx1]
or, to get at a single Char: ZString[idx1][idx2] (byref access)
This has worked ever since, through from ver. 0.24.0 to current (incl. 1.05.0).
(I've not yet tested the 1.06.0 versions, 32/64.)
Of course not ;-)counting_pine wrote:As is, those obviously don't compile.
Code: Select all
'' this is part of a WIN-DLL (FBC 32, only)
Sub CCalculateEx ( _
ByVal PInput As Double Ptr, _
ByVal POutput As Double Ptr, _
ByVal PUser As Double Ptr, _
ByVal PStrings As ZString Ptr Ptr _
) Export
If CInt(PInput[_MSB]) > 2 Then ' Integer compare (way faster than double)
*PStrings[SO] = Single2String(CSng(PInput[_SNG])) ' implicit second param. val = 0
Else ' result = MSB first
*PStrings[SO] = Single2String(CSng(PInput[_SNG]), 5) ' anything but 0. user supplied (Integer range)
EndIf ' result = LSB first
End Sub
'' Single2String() is: Private Function(ByVal As Single, ByVal As Byte = 0) As String '' not exported by DLL
... in FreeBasic.counting_pine wrote:Things like this just serve to highlight how unexpectedly complicated zstrings are
Code: Select all
#include once "crt/string.bi"
#include once "crt/stdio.bi"
scope
print "UBYTE PTR is a char *"
dim s as ubyte ptr = callocate( 100 )
strcpy( s, @"string")
printf( !" char * is a string '%s'\n", s )
printf( !" char * is a char '%c'\n", *s )
printf( !" char * is a value '%d'\n", *s )
'' *s = ucase( *s) '' not-allowed with UBYTE PTR
print " s[0] = "; s[0] '' print a char value
print " s[1] = "; s[1] '' print a char value
print " *(s+1) = "; *(s+1) '' print a char value
deallocate( s )
end scope
Code: Select all
scope
print "STRING"
dim s as string
s = "string"
print " string is a string '"; s; "''"
print " string is a char '"; chr(s[0]); "''"
print " string is a value '"; cubyte(s[0]); "'"
s = ucase(s)
print " s[0] = "; s[0] '' print a char value
print " s[1] = "; s[1] '' print a char value
print " *(s+1) = "; asc(mid(s,2,1)) '' print a char value
end scope
Code: Select all
scope
print "ZSTRING PTR is a char *, sort of"
dim s as zstring ptr = callocate( 100 )
*s = "string"
print " zstring is a string '"; *s ; "'"
print " zstring is a char '"; mid(*s,1,1) ; "'"
print " zstring is a value '"; asc(s[0]) ; "'"
*s = ucase( *s ) '' allowed with zstring in fbc
print " s[0] = "; s[0] '' print a string
print " s[1] = "; s[1] '' print a string
print " *(s+1) = "; *(s+1) '' print a string
deallocate( s )
end scope