i see some shared and protected command for some functions, but still didnt understand i am starting think i need that command, because i have problem.
prelude:
1. i have a lot of enumerations. i have a tonns gadgets. and yes, i set file's id to top of list.
2. i have big complex array with images.
3. i use some fonts for drawtext over images.
4. i have some big memory allocation for some playing music with specific format.
5. i am didnt used explit. yes, i know it is not very well... but that explite is very intrusive. every variable need to define. bored thing...
6. i have a tonns global variables
problem is:
program starts. fonts work fine and make drawtext when i paint some images work fine. then i start some music - it just read some files, convert them into data and write in a memory, then send that memory to external library (but that lib is use from memory, was included inside main exe). it plays fine. then i get back to any place, where i use drawtext - that text is disapear.
so my question is how working with a memory can corrupt font's working? maybe i need make some protected for that fonts... IsFont says it is ok, DrawText is return some value, color is fine. where can be my mistake??? i am crying... i thought finaly i am finish it - and that glitch is appear. start to think make some FreeFont and loag it back after playing. but it is not root of problem.
shared and protected? font's problem. [solved]
-
- Enthusiast
- Posts: 617
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
shared and protected? font's problem. [solved]
Last edited by SeregaZ on Tue May 04, 2021 12:45 pm, edited 1 time in total.
Re: shared and protected? font's problem.
It's impossible to help you without see the complete code.
And now you can think about the question:
What takes longer? Defining all variables, or finding such a fault.
Since you don't know from where the fault is coming,
You have to search for all variables and memories which are involved in the font problem.
I only can recommend:
EnableExplicit
No Global variables until they are really really needed.
Protected is for variables which are only used inside of the procedure.
Shared is nearly like Global, it allows you to access a variable from outside, inside of the procedure
So you can avoid Global which may ensure that this variable is not accidently used in a procedure where it should not be used.
And now you can think about the question:
What takes longer? Defining all variables, or finding such a fault.
Since you don't know from where the fault is coming,
You have to search for all variables and memories which are involved in the font problem.
I only can recommend:
EnableExplicit
No Global variables until they are really really needed.
Protected is for variables which are only used inside of the procedure.
Shared is nearly like Global, it allows you to access a variable from outside, inside of the procedure
So you can avoid Global which may ensure that this variable is not accidently used in a procedure where it should not be used.
-
- Enthusiast
- Posts: 617
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: shared and protected? font's problem.
i am very accurate with name for global variables. to avoide crossing - just add some prefix of that part of code. if that Metatile editor - METAEDsomename, if Map editor - MAPEDsomename...
but i have many of that Global variables. it have some limits?
i cant to make small code with that problem. it work fine. not fine when it is a full project. will search...
but anyway how is that passible - broke all fonts, or all DrawText that was used later, after music playing. i check every part, where i make DrawText - they all dead no any text appear. it is different places. i am agree, if that was one place with one font, but i have four fonts - and different gadget and image, where DrawText happen. how i can write something in a memory, that was attached for font? of for PB's DrawText function. i am confuse, but will try to find that
but i have many of that Global variables. it have some limits?
i cant to make small code with that problem. it work fine. not fine when it is a full project. will search...
but anyway how is that passible - broke all fonts, or all DrawText that was used later, after music playing. i check every part, where i make DrawText - they all dead no any text appear. it is different places. i am agree, if that was one place with one font, but i have four fonts - and different gadget and image, where DrawText happen. how i can write something in a memory, that was attached for font? of for PB's DrawText function. i am confuse, but will try to find that
Re: shared and protected? font's problem.
You have to check also each line where you do something with memories:
Poke
CopyMemory
MoveMemory
FreeMemory
AlocateMemory
In general it sounds that you overwrite something.
Maybe you can use the Purifier (compiler options) with
Poke
CopyMemory
MoveMemory
FreeMemory
AlocateMemory
In general it sounds that you overwrite something.
Maybe you can use the Purifier (compiler options) with
Code: Select all
PurifierGranularity(1, 1, 1, 1)
-
- Enthusiast
- Posts: 617
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: shared and protected? font's problem.
for playing music i use external dll. it have some order commands to make song play. i have a few place - where it create memory banks and then send into dll for play. that place have the same order everywhere.
when it plays at main window - it will broke DrawText. but when i comment that string GEMSSet28mode(1) - it start work fine. but how is that possible? remember? i have few place with same code for start play. they play fine and not broke DrawText. only this is one is do that.
Code: Select all
GEMSStop()
GEMSSet28mode(1)
GEMSPlay()
-
- Enthusiast
- Posts: 617
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: shared and protected? font's problem.
PrototypeC for including dll is save my world. before it was Prototype
Re: shared and protected? font's problem.
Can you edit your post title if it is solved?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum