Search found 18 matches

by Martt
Sun Jul 14, 2024 12:40 pm
Forum: Coding Questions
Topic: SOLVED - Why doesn't this work (round a float via a procedure) ???
Replies: 6
Views: 902

Re: Why doesn't this work (round a float via a procedure) ???

Ok, thanks for the explanations, everybody. Looks like I picked up a bad habit along the way.

In this case it kind of sucks, since I'm working on a RayLib program, and RayLib uses floats everywhere.
It's only 40K lines to check. Search If....... I need a drink.... :oops: :evil:
by Martt
Sun Jul 14, 2024 11:03 am
Forum: Coding Questions
Topic: SOLVED - Why doesn't this work (round a float via a procedure) ???
Replies: 6
Views: 902

Re: Why doesn't this work (round a float via a procedure) ???


A float is not an expression.

You can do it like this:
If Int(Bounds\x) And Int(Bounds\y)
Or like this (better solution)
If Bounds\x <> 0 And Bounds\y <> 0


I know that <> #Null works fine. But If with a zero number should always return False. I'm using that all the time, never fails. And ...
by Martt
Sun Jul 14, 2024 10:36 am
Forum: Coding Questions
Topic: SOLVED - Why doesn't this work (round a float via a procedure) ???
Replies: 6
Views: 902

SOLVED - Why doesn't this work (round a float via a procedure) ???

Hi,

I do not understand why the following code returns #True, since it should be #False.
Not using the procedure and using a manual Round function works fine.
But this should work imho...

Hmm, Asm compiler (x86 and x64) returns #True, but C compiler (x86 and x64) returns #False). Strange ...
by Martt
Fri Jan 22, 2021 8:30 am
Forum: Tricks 'n' Tips
Topic: Buddy Windows
Replies: 12
Views: 7269

Re: Buddy Windows

Better late then never, I guess :oops: :oops:

I made a small modification to the code, so the windows will also snap when they are moved within the grab zone.
Thanks for the initial code. :!:

; Buddy Windows by netmaestro (https://www.purebasic.fr/english/viewtopic.php?f=12&t=30316&hilit=Buddy ...
by Martt
Fri Oct 30, 2020 9:28 am
Forum: Coding Questions
Topic: Mod function returning the same value as the Divisor
Replies: 7
Views: 1831

Re: Mod function returning the same value as the Divisor

Tawbie wrote:Hi Norm,

The issue with floats here is not the range that they support but the precision with which a float can represent a decimal number, before rounding occurs.
Or you use mpdecimal library https://www.bytereef.org/mpdecimal/
by Martt
Thu Aug 20, 2020 12:06 pm
Forum: Tricks 'n' Tips
Topic: Module System (PB-Internals)
Replies: 18
Views: 14337

Re: Module System (PB-Internals)

mk-soft wrote:Here is a cleaned module with system functions which is needed from time to time

Code: Select all

  ; Force Import Fonts
  If 0 : LoadFont(0, "", 9) : EndIf
If 0 doesn't get executed. What is this supposed todo ?
by Martt
Sat May 09, 2020 8:22 am
Forum: Coding Questions
Topic: CompilerIf doesn't do short-circuit ?
Replies: 7
Views: 2023

Re: CompilerIf doesn't do short-circuit ?

@JagV12: I thought I tested this a while ago, but v5.62 also doesn't do it. Looks like it never worked that way. I allways try to use one line If's. Cleaner code.

@Fred: Thanks for the explanation.
by Martt
Fri May 08, 2020 12:31 pm
Forum: Coding Questions
Topic: CompilerIf doesn't do short-circuit ?
Replies: 7
Views: 2023

Re: CompilerIf doesn't do short-circuit ?

A semicolon in PureBasic is used to denote a comment. You don't need them in front of constants. Remove it and it'll work.

Of course it works without the semicolon. The whole point is to check if a constant exists (part 1). If it doesn't exist the second part should not be checked.
That is what ...
by Martt
Fri May 08, 2020 10:53 am
Forum: Coding Questions
Topic: CompilerIf doesn't do short-circuit ?
Replies: 7
Views: 2023

CompilerIf doesn't do short-circuit ?

PB does support short-circuit ( https://en.wikipedia.org/wiki/Short-circuit_evaluation ). Very helpfull.

The following code in 5.71 and 5.72 does not work (constant not found: #Test):

;#Test = #True

CompilerIf Defined(Test, #PB_Constant) And #Test
Debug "Hi there"
CompilerEndIf


Is there a ...
by Martt
Sun Jun 02, 2019 2:49 pm
Forum: Coding Questions
Topic: FindData from Wilbert and Purifier ?
Replies: 0
Views: 1076

FindData from Wilbert and Purifier ?

Hi,

I use FindData from Wilbert ( http://forums.purebasic.com/english/viewtopic.php?f=12&t=62519 , the July 24 2018 version.
I understand that FindData uses just about every cpu register available, so I use DisableDebugger before and EnableDebugger afterward. Works fine.

Because I use FastString ...
by Martt
Thu Mar 22, 2018 3:33 pm
Forum: Coding Questions
Topic: Disable TreeGadget Item
Replies: 15
Views: 3713

Re: Disable TreeGadget Item

Ok. Thanks for explaining that. Thanks to all who helped.
by Martt
Thu Mar 22, 2018 10:54 am
Forum: Coding Questions
Topic: Disable TreeGadget Item
Replies: 15
Views: 3713

Re: Disable TreeGadget Item

Structure StructNMTVITEMCHANGE Align #PB_Structure_AlignC
hdr.NMHDR
uChanged.l
hItem.i
uStateNew.l
uStateOld.l
lParam.i
EndStructure

Structure Struct2NMTVITEMCHANGE
hdr.NMHDR
uChanged.l
PB_Alignment.b[4]
hItem.i
uStateNew.l
uStateOld.l
lParam.i
EndStructure

Debug "With ALignC"
Debug ...
by Martt
Thu Mar 22, 2018 9:00 am
Forum: Coding Questions
Topic: Disable TreeGadget Item
Replies: 15
Views: 3713

Re: Disable TreeGadget Item

Nothing is changed from .i to .l.

This works fine
Structure StructNMTVITEMCHANGE Align #PB_Structure_AlignC
hdr.NMHDR
uChanged.l
hItem.i
uStateNew.l
uStateOld.l
lParam.i
EndStructure

This does not work:
Structure StructNMTVITEMCHANGE; Align #PB_Structure_AlignC
hdr.NMHDR
uChanged.l ...
by Martt
Wed Mar 21, 2018 1:03 pm
Forum: Coding Questions
Topic: Disable TreeGadget Item
Replies: 15
Views: 3713

Re: Disable TreeGadget Item

Yes, I found the pb event way. Works very well. I like the api way better, for my project anyway.

You can disable a item, but the user can still interact. It is only gray. This one does work:
EnableExplicit

Enumeration
#Window
#Tree
#Image1
#Image2
EndEnumeration

; These ones are not present ...
by Martt
Wed Mar 21, 2018 9:36 am
Forum: Coding Questions
Topic: Disable TreeGadget Item
Replies: 15
Views: 3713

Re: Disable TreeGadget Item

Thanks Rashad. The route you took did come to mind, mouse and keyboard. But after a lot of experimenting with EditorGadgets and that stuff, I abandoned the idea. Something always breaks or does not work 100% all the time. Very annoying.

But I did answer my own question. This puppy finally works ...