Search found 1794 matches

by STARGÅTE
Sun Apr 07, 2024 6:53 pm
Forum: Coding Questions
Topic: How to create constants automatically?
Replies: 12
Views: 459

Re: How to create constants automatically?

A constant is just a macro with a hashtag. Once defined, it is replace everywhere during the compilation and is not present anymore in the final executable. I think at this point the discussion is closed. When you want to define a constant from another file (during compilation), you can use IncludeF...
by STARGÅTE
Sun Apr 07, 2024 7:06 am
Forum: Coding Questions
Topic: What variable type is "?" for CatchImage?
Replies: 7
Views: 306

Re: What variable type is "?" for CatchImage?

The second argument in CatchImage() is just a memory address. The ? operator is used to receive the memory address from a label: *Address = ? Label CatchImageEnhanced(#GLOBAL_IMAGE_POPUP_EDIT,?popup_edit,"Can't load image.") Procedure CatchImageEnhanced(MARCOAGPINTO_gadget, *Buffer, MARCOA...
by STARGÅTE
Fri Apr 05, 2024 3:49 pm
Forum: Bugs - Windows
Topic: [Done] Sound channel not working properly
Replies: 10
Views: 342

Re: Sound channel not working properly

The channel is not linked to the sound, it's allocated dynamically (you can define a max number of channels in InitSound()) Ahh, that's a new feature, never saw this. It is also not visible in the online documentation: InitSound() Does this mean, if I use InitSound(16), I have only 16 channels in t...
by STARGÅTE
Fri Apr 05, 2024 2:04 pm
Forum: Bugs - Windows
Topic: [Done] Sound channel not working properly
Replies: 10
Views: 342

Re: Sound channel not working properly

infratec wrote: Fri Apr 05, 2024 1:58 pm In my opinion nothing should be heard, because all sounds are paused correct.
Yes, that's also my opinion.

What I was meant was, the returned channel number do not have to be unique, because it is connected to the sound number as well, or am I wrong?
by STARGÅTE
Fri Apr 05, 2024 1:45 pm
Forum: Bugs - Windows
Topic: [Done] Sound channel not working properly
Replies: 10
Views: 342

Re: Sound channel not working properly

The number of the channel is not a global parameter. Each sound number has his own set of channels in which the sound is played. Therefore, Pure Basic functions like PauseSound need the sound number as well as the channel (and not only the channel). If you play #SND_EARTH_CITY, #SND_CONSTRUCTION_LOW...
by STARGÅTE
Fri Apr 05, 2024 11:21 am
Forum: Bugs - Windows
Topic: [Done] LoadImage crashes on faulty BMP-image
Replies: 10
Views: 480

Re: LoadImage crashes on faulty BMP-image

But that mean the compiler should check for 1- Bad format 2- Bad image header magic number 3- No image but image extension(Bad guy idea) And maybe more Not the compiler, but the function LoadImage. Yes of course, that's the task of the function not of the user. Otherwise I have to write my own load...
by STARGÅTE
Fri Apr 05, 2024 5:50 am
Forum: Bugs - Windows
Topic: [Done] LoadImage crashes on faulty BMP-image
Replies: 10
Views: 480

Re: LoadImage crashes on faulty BMP-image

RASHAD wrote: Fri Apr 05, 2024 5:21 am So it's the coder part to avoid the crash when using PB :wink:
No. A language function should never crash, because of incompatible input data. (LoadImage, LoadSound, LoadSprite, etc.)
A language function should return 0 is such cases, but not crash.

It is some kind of security risk.
by STARGÅTE
Wed Apr 03, 2024 6:10 pm
Forum: Bugs - Windows
Topic: PB 6.10 x86 ASM-backend - IMA at DeleteMapElement() with key
Replies: 3
Views: 243

PB 6.10 x86 ASM-backend - IMA at DeleteMapElement() with key

This code generates an IMA during the call of DeleteMapElement(). This problem only occurs with explicit key definition, only in x86, only in the ASM backend, and only with debugger on. Define NewMap Test.i() Define I.i For I = 1 To 100 AddMapElement(Test(),Str(I)) Next Debug MapSize(Test()) For I =...
by STARGÅTE
Wed Apr 03, 2024 10:08 am
Forum: Coding Questions
Topic: Beginner searching for his learning path
Replies: 16
Views: 814

Re: Beginner searching for his learning path

The only problem is.. where the start? So that's where you might be able to help me out! I know nothing about programming at the moment. So any fancy terms you throw at me are wizardry right know :D The goal is to be able to build some simple games at some point, pong would be the ultimate first go...
by STARGÅTE
Tue Apr 02, 2024 8:07 pm
Forum: Coding Questions
Topic: What is the usecase for BeginVectorLayer()/EndVectorLayer()
Replies: 3
Views: 187

Re: What is the usecase for BeginVectorLayer()/EndVectorLayer()

I use BeginVectorLayer() when I want to draw a set of overlapping figures in a half transparent way.
Without a layer, the individual figures would also blend each other.
by STARGÅTE
Mon Apr 01, 2024 4:43 pm
Forum: Tricks 'n' Tips
Topic: Revised Chr() & Asc() for UTF-16 surrogate pairs
Replies: 19
Views: 5240

Re: Revised Chr() & Asc() for UTF-16 surrogate pairs

I think your last version is the slowest due to several calls to other procedures. When we talk about speed, than we should avoid division of $400: Procedure.s _Chr(Unicode.i) Protected String.s{2} Protected *Long.Long = @String If Unicode < $10000 *Long\l = Unicode Else Unicode - $10000 *Long\l = ...
by STARGÅTE
Mon Apr 01, 2024 8:21 am
Forum: Tricks 'n' Tips
Topic: Revised Chr() & Asc() for UTF-16 surrogate pairs
Replies: 19
Views: 5240

Re: Revised Chr() & Asc() for UTF-16 surrogate pairs

Little John wrote: Sun Mar 31, 2024 8:53 pm STARGÅTE, you saved my program.
Thank you very much!
Actually, I did a mistake. PeekS only needs to read 1 character.

Code: Select all

ProcedureReturn PeekS(@high, 1, #PB_Unicode) + PeekS(@low, 1, #PB_Unicode)
by STARGÅTE
Sun Mar 31, 2024 7:01 pm
Forum: Tricks 'n' Tips
Topic: Revised Chr() & Asc() for UTF-16 surrogate pairs
Replies: 19
Views: 5240

Re: Revised Chr() & Asc() for UTF-16 surrogate pairs

Little John wrote: Sun Mar 31, 2024 5:36 pm How can we get UTF-16 surrogate pairs for characters > $FFFF e.g. with PB 6.04 and PB 6.10 :?:
Just replace Chr() with PeekS(@high, 2, #PB_Unicode) and PeekS(@low, 2, #PB_Unicode).
Little John wrote: Sun Mar 31, 2024 5:36 pm Where ist the change with PureBasic's Chr() function documented?
please remove range test from chr()
by STARGÅTE
Sun Mar 31, 2024 9:13 am
Forum: Coding Questions
Topic: Compress a string
Replies: 1
Views: 155

Re: Compress a string

Here is an example. You need the Packer library and the Database library You can pack (compress) the string and store it as a BLOB type in the database. Enumeration #File #Database EndEnumeration UseSQLiteDatabase() UseLZMAPacker() ; Create Database Define DatabaseFile.s = GetTemporaryDirectory() + ...
by STARGÅTE
Sat Mar 30, 2024 10:41 am
Forum: Coding Questions
Topic: AES+Base64 encryption
Replies: 4
Views: 174

Re: AES+Base64 encryption

Your code still mixed up byte length and character length. I know, for characters between code points 0 and 127 it is the same, but having a correct code prevents later errors when using higher code points. If you want to allocate memory for an UTF8-encoded string, you have to use: *Buffer = Allocat...