Page 6 of 16
Posted: Sun Jan 04, 2004 3:34 pm
by Kale
> About the 64k buffer:
> Personally, i have never hit that limit.
One such example: using the GetClipboardText() command will CRASH
your app if the clipboard holds more than 64K of data, essentially making
this command quite useless. That's why I'd like to see unlimited strings.
(In the meantime, I'm using a custom GetClipboardText command that
only gets the first 64K of text. Not a great solution at all, but necessary).
This can handle any size text
Code: Select all
OpenClipboard_(#NULL)
If IsClipboardFormatAvailable_(#CF_TEXT) <> 0
hStrPtr.l = GetClipboardData_(#CF_TEXT)
If hStrPtr <> 0
;Only display the first 30 characters of the Clipboard text!
Debug PeekS(hStrPtr, 30) ; This command is subject to the >64k limit.
SetWindowText_(GadgetID(#StringGadget), hStrPtr) ; Fill a gadget with the text.
EndIf
EndIf
CloseClipboard_()
EDIT: Added a way to fill a gadget with text that gets around the >64k string limit.
Posted: Sun Jan 04, 2004 4:15 pm
by Dare2
Lots of entrenched positions, it seems
Some quick thoughts on different variable types, strings and the like.
1. More variable types:
Adding additional variable types surely will not add
that much overhead to the final prog, and a little extra in the core might mean a little less in the workarounds.
Additional variable types may make it easier to talk to other code (libs, etc).
2. Strings.
Leave strings as-is.
Create a new data type called a blob (big lump of binary or whatever) which can fixed length (set by programmer) and which can be used for anything. Let it have an internal VLI to control the length. The overhead here is then mainly the programmer's responsibility (and mainly effects memory usage?).
----
On the wish list generally, and something that most people using PB might not need - more documentation.
Docs will put PB a little further ahead of the rest.
PB's docs/help is good-ish, however there is also a fair amount of assumption involved.
Perhaps some stand-alone tutorials with "why" as well as "how" and a walk-through or two?
I know writing docs is boring but I bet you that it will have a good marketing effect.
My 2c.
Posted: Mon Jan 05, 2004 1:51 am
by PB
> This can handle any size text
But you're using "PeekS(hStrPtr, 30)" so you're only getting the first 30
characters from the clipboard... I'd hardly call that "any size text". How
does your example handle any size text?
Posted: Mon Jan 05, 2004 2:33 am
by newbie
My Whishlist :
1) Boolean type variable : i use very often variable which are "0" or "1" (false or true) and i have to declare them as byte "var1.b" which use more memory (with many variables, the difference is big).
2) "char" variable declarable with "var1.c" which would be only a letter, actually i have to declare a whole string even if i know it will store a single character.
3) unsigned type variables : most of the time in my programs i never use negative numbers, so i would like to be able to specify more accuratly variable type.
That's all for now

Posted: Mon Jan 05, 2004 2:40 am
by Kale
@PB
PeekS(hStrPtr, 30) was used just to show you a preview of the text contained within the memory buffer. Of course PeekS() is subject to the 64k limit. The native command
GetClipboardText() also is subject to the 64k limit however the piece of code i posted (other than the PeekS()) is not. Just replace the PeekS() command with:
Code: Select all
SetWindowText_(GadgetID(#StringGadget), hStrPtr)
and your away...

Posted: Mon Jan 05, 2004 4:10 am
by PB
> Just replace the PeekS() command with:
> SetWindowText_(GadgetID(#StringGadget), hStrPtr)
Cool, thanks Kale!

Posted: Mon Jan 05, 2004 11:26 am
by Dr. Dri
débutant wrote:My Whishlist :
2) "char" variable declarable with "var1.c" which would be only a letter, actually i have to declare a whole string even if i know it will store a single character.
C'est bien bô de vouloir un type caractere, mais jettons un coup d'oeil au type byte en lui meme. Il est défini sur 8 bit, donc un octet, tout comme un caractere ascii. malheureusement il est signé. Et bien je vais t'apprendre que par le comlpément à deux tu peut etre bien récupérer ces codes ascii. car un byte signé négatif correspond à un autre byte non signé, mais qui tous deux auront le meme ascii.
essaye ceci :
tu déclare un caractere, char.b
tu lui met une valeur négative
tu affiche le caractere
Code: Select all
debug chr(char) ;me rappelle pas comment on fait pour un caractere
et tu fais ceci
tu devrai récupérer le meme ascii que celui du caractere affiché
de meme, fait ensuite avec cet ascii ke tu as récupéré
char = "valeur positive supérieure au max d'un byte"
debug ton char et il aura la valeur négative que tu as entrée au début
English version :
char type would be useless
Dri
Posted: Mon Jan 05, 2004 11:45 am
by freedimension
@Anfänger/newbie/debutant/principiante
1) Boolean type variable
Almost every language implements booleans by reserving a byte or even a long for it (cause it's faster).
2) "char" variable
Use the Byte type, as it's exactly the same as in other languages. For assigning a char use the single quote character as delimiter ( 'a' ).
3) unsigned type variables
Yes, that's very needed but also very often aked for, just look at all the other postings on this subject.
Posted: Mon Jan 05, 2004 11:54 am
by Dare2
Or char type is an excellent nominee for fixed length binary strings. Eg:
myFixStr.c ; 1 byte
myFixStr.c1 ; 1 byte
myFixStr.c19 ; 19 bytes
And makes for a nice one-byte
unsigned datatype when reading in data
tinyFileBuffer.c = ReadByte()
Posted: Mon Jan 05, 2004 11:56 am
by blueznl
fixed length strings? did anybody say fixed length strings?!?
from...
bytes.b[10]
to...
fixed.c[10]
i'd love it...
Posted: Mon Jan 05, 2004 2:22 pm
by newbie
so i can say var1.b = 'h' ??
i never tried that, i always used to do : var1.s = "h"
i will test that now
EDIT :
ok, this works :
Code: Select all
char.b
char = 'd'
Debug "char = " + Chr(char)
I never thought to that, really sorry... i'm a newbie after all
And so, about boolean, i didn't know that other languages were allocated one byte, so i'm now in love with the "byte" variable type
It just remain the unsigned variable, and yea i see people talking about it,
but i wanted to show that me too i would want it

Posted: Tue Jan 06, 2004 6:12 am
by Dare2
Another wish:
Let PureBasic have aha! moments. So, for example, on encountering
someGadget(#gadget,arg,arg, ..)
it will, on finding that the gadgetList was not created, say AHA! and just create one for the window currently in use.
Or is there some reason why this is bad?
Posted: Wed Jan 07, 2004 10:52 am
by Psychophanta
Another:
Please, please: a checkbox in "COMPILER OPTIONS" for "CASE SENSITIVE SOURCE TRANSLATION"
It should be so easy to do... :roll:
AL
Posted: Wed Jan 07, 2004 12:09 pm
by blueznl
no psycho, don't even suggest to us purebasic lovers to go through the 'case (in)sensitive' discussion again

Posted: Wed Jan 07, 2004 12:49 pm
by Danilo
The case (in)sensitive thing doesnt make sense.
Its the option 'Explicite' which is missing (and i think its on
Frederics ToDo-List), so the compiler gives a warning/error
if you didnt declare a variable before.
Example:
Code: Select all
Explicite
MyVariable.l = 12
...20000 lines of code...
If MyVarable = 12
; do something
EndIf
The compiler will stop here at 'MyVarable' because it wasnt
declared before because its a typo.