Wishlist for PureBasic v4.0

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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.
Last edited by Kale on Mon Jan 05, 2004 2:45 am, edited 3 times in total.
--Kale

Image
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Lots of entrenched positions, it seems :D

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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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?
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

Post 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 :)
- Registered PB user -

Using PB 4.00
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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... :D
--Kale

Image
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Just replace the PeekS() command with:
> SetWindowText_(GadgetID(#StringGadget), hStrPtr)

Cool, thanks Kale! :)
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post 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

Code: Select all

char = -10
tu affiche le caractere

Code: Select all

debug chr(char) ;me rappelle pas comment on fait pour un caractere
et tu fais ceci

Code: Select all

debug (~char + 1) % 255
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
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post 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.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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()
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

fixed length strings? did anybody say fixed length strings?!?

:-)

from...

bytes.b[10]

to...

fixed.c[10]

i'd love it...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

Post 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 :D

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 :D

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 :)
- Registered PB user -

Using PB 4.00
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Another:

Please, please: a checkbox in "COMPILER OPTIONS" for "CASE SENSITIVE SOURCE TRANSLATION" :idea:
It should be so easy to do... :roll:

AL
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

no psycho, don't even suggest to us purebasic lovers to go through the 'case (in)sensitive' discussion again :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post 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.
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
Post Reply