View Full Version : Rene's project consulting
ReneMiner
25-10-2012, 13:18
Don't know why, but my script runs without any errors and if I end it, I receive this message:
http://imageshack.us/a/img163/4835/strange2.png (http://imageshack.us/photo/my-images/163/strange2.png/)
means the method "read" could not be done somewhere in memory.
The numbers vary, so they won't tell anything in detail. thinAir keeps running, even if I click on OK.
Problem is, if I restart my script thereafter, it starts tossing Errors randomly or it stops running the program without any message.
This behavior goes on, until I reboot the computer. Then my program runs once till I end it, this message appears again and thereafter the whole procedure repeats.
First I thought it would be too many if/select-case-clauses inside for-next loop, commented them out or took 'em all out. Now I've read in this forum that their might be something with parenthesis. So - would it be better not to use parenthesis for calling subs & functions and to use them just for math-reasons?
My program is totally undone, but already a few dozen kB long, loads loads of external resources like images & sounds, I've used your code from above (#includes "unit_Sound3d.tBasicU" etc.), thereafter uses "UI", "FILE", "TBGL".
I'm doing just sprites, use *.bmp-Format and it has something to do with them sprites. If I run my code without drawing them nothing strange happens.
Maybe I'll get the code stripped down later today to localize the reason and quarantine it.
But its so much effort to always reboot. Just restarting thinAir does not help.
Another thing is a missing function to TBGL_Sprite...: Exists.
There should be something like
if TBGL_SpriteExists(SpriteNum) then
' it can draw the sprite
else
' if I tell to draw a sprite that does not exist, it crashes
' it could also give an error-message like "invalid sprite-call"
endif
Petr Schreiber
25-10-2012, 14:06
Hi Renne,
I developed the TBGL_SpriteExists for you, you can download new TBGL with updated help file here:
Latest TBGL (http://www.thinbasic.com/community/showthread.php?10909-The-latest-TBGL-version&p=81635#post81635) (it will be added to next ThinBASIC release)
Regarding the crashes - I am not sure what could be the case. Do you think you could upload somewhere test script which crashes, so we could test it?
Using parenthesis should be okay :)
Petr
ReneMiner
25-10-2012, 14:47
Sprite-Exists- already built-in? That's pretty fast- wow!
I'm still stripping the code down, to isolate the problem. But it'll still need a few hours, cause I always have to reboot for every test. I'm down to 19 kB already. If it's 5 or less left I will send it.
EDIT: Strange... You just added SpriteExists to TBGL or something more?
I downloaded it, put it in the tb-folder, rebootet and it does not do it any more! The effect is gone! I did not change my script!
I just was up to add some comments in front of my script before I rebooted, where I discovered the line
%Sound3D_WantTBGL = 0 and I thought, this could be the reason and I wanted to change it right now, this attempt. But I started it first, and now there's no more message, even if I draw sprites.
Edit2:
The TBGL_SpriteExists does not show up in bold letters if I type it (but it's documented in Help-File).
I guess it has something to do with type of variables. Now I try to change all my constants to long. Does it work like
Begin Const
%Mode_Menu = 1 as Long
%Mode_Play
%Mode_Options
end Const
to make all long-types? Or is %Mode_Play and %Mode_Options still variant-type then?
ReneMiner
25-10-2012, 16:16
I uploaded all the stuff together http://www.filefactory.com/file/35vxxpuln5l1/n/tBProblem_zip (just scroll down use slow download)
It does not happen always at the first try now, but if it has happened there's just a reboot.
Keys to press
F3 to switch to editor-mode
esc to leave Editor-Mode + end program from Menu-Mode
if you comment line 468 out it does not happen since there are no sprites to draw. But their numbers & posiitions are OK, as you can see - it works.
but after ending the program it's all messed up. (just try a second run to see it)
line 475 to 481 are comented out. If you remove the comment-signs it crashes instantly with strange, (wrong) Error-Descriptions
another problem I have within the lines 578 to 595 (maybe I've overseen something)
it should display the number of the currently pointed-at-sprite-number in title-bar as it does for game-area(the dark rectangle)
but it does not go into the if!
It's that long because of the media. By accident the sprites are double in there (the tga's I've changed to bmp's since TBGL didn't like my tga's format)
Script itself has just 18855 Bytes.
if you want to see the finished program that I want to port to tB you might play here: http://www.filefactory.com/file/45pdp5x3mz2t/n/Locker-Unlocker_7z), I'm gonna reboot in the meantime...
Petr Schreiber
25-10-2012, 18:16
Hi Rene,
I am just leaving work, so briefly:
to make TBGL_SpriteExists colored, thinAIR needs to know it has been added :). To do so, please run:
\thinBasic\thinAir\Syntax\thinBasic\thinBasic.CreateSyntaxIni.tBasic and restart ThinAIR
I add things to TBGL from time to time, I cover the new features with article once ThinBASIC release is out.
The %constants are Long by default
Once I reach home, I will download your files and see, where the problem could be :)
Petr
Petr Schreiber
25-10-2012, 20:24
Hi Rene,
I sent you private message with something to test ;).
Petr
ReneMiner
25-10-2012, 20:28
Strange... I edited a little bit on my file, rebooted now and started the "old" *.tBasic- file from the folder that I've uploaded. (Not from thinAir-IDE) and it run. Ended without an Error...
Now I've tried the same from thinAir-IDE and now it even displays the tile that the pointer's at. I don't get it. Now my in the meantime changed file( http://www.filefactory.com/file/6k7g4vgq8lj7/n/LockerUnlocker2_tbasic ) shows that message (see very first post) but the old one (that I've already uploaded) does not... it all goes crazy. The only things that are changed is 3 lines (in new file 629, 631, 633) that shall prevent from starting if sprites-images are not complete and I took UDT aTexturelist out. Now the old one runs (after I started it first since Reboot from Explorer) the new one (started first from IDE) crashes. There are just five or six lines different in total.
THIS WAS BEFORE I'VE READ PM (got it while typing this!)
ReneMiner
25-10-2012, 20:48
After following your instructions that you've send by PM, I proudly announce the first run from IDE successful ended with no crash. Even the unstripped version with ~150 kB runs now perfectly (last uploaded it was a typo: used & instead of %). Now I can continue :D
Petr Schreiber
25-10-2012, 20:48
The uploaded file has a little issue it seems, on line 747:
For lZ = &snd_Disappear To %Snd_Beep
should be:
For lZ = %snd_Disappear To %Snd_Beep
After the fix it works okay for me. Sometimes the strange things can happen due to antivirus software, do you use some?
Petr
P.S. Little tip - you can attach files to posts. When editing post, click Manage attachements and you can upload files, like *.tBasic or *.zip
EDIT: I didn't see your previous posts at the time of writing this :)
ReneMiner
25-10-2012, 20:54
Yes, of course I use antivirus-software. And uploading files or images I've overseen. I tried to add an image above the type-in-field, where you can click bold,italics, add image etc. but it just takes URL, not upload. So I thought this would be the way.
But something else about sprites: Set/GetLayer. I thought that should order the sequential arrangement of drawing. So sprites on low-number layer get drawn first, high number layer later. But it does not seem to affect this order. Is there some Z-Order-method or do I have to draw them separately the order I want them and not using SpritesDrawAll
Petr Schreiber
25-10-2012, 21:14
I think the layers should work okay.
Just make sure you have depth testing enabled. In your example I can see:
TBGL_UseDepth %FALSE
...which basically disables depth testing.
Petr
ReneMiner
25-10-2012, 21:39
yeah, that line I probably just copied with the whole bunch of render-settings from code-example (sprite_sheet). Overseen that.
Another "thanks"!
But by the way, I experienced that, if I use an unfixed tbgl_window-border (so it can be resized) the content of the window gets resized fitting proportional to the window. Even the sprites. Thats ok, nice, I won't complain. For fast calculation-purposes I had a small suggestion for
Get/Set-MousePos-X/Y. Maybe it could be set to a value of X= 1.0 if the mouse is full right and 0.0 on the left side? You know what I mean?
So I can use Mouse-coordinates from 0.0 to 1.0 without any recalculating when windows size was changed.
just like
TBGL_MouseInPixel = %TRUE
TBGL_ShowWindow
TBGL_MouseGetPosX+Y results now the usual pixel-coords
TBGL_MouseInPixel = %False
TBGL_ShowWindow
TBGL_MouseGetPosX+Y results now values from 0.0 to 1.0
This is just necessary for the mouse-coords since sprites get resized to the right size and positioned to the right place already by TBGL.
Petr Schreiber
25-10-2012, 21:52
Interesting concept, I will think about it.
For the moment, you can use this code:
Function GetNormalisedMouseX( hWnd As DWord ) As Single
Long width, height
TBGL_GetWindowClient(hWnd, width, height)
Return TBGL_MouseGetPosX/width
End Function
Function GetNormalisedMouseY( hWnd As DWord ) As Single
Long width, height
TBGL_GetWindowClient(hWnd, width, height)
Return TBGL_MouseGetPosY/height
End Function
The hWnd is the handle of TBGL window.
Petr
ReneMiner
25-10-2012, 21:57
Sure, I know how to calc this, but basic might be a little bit slower...
ReneMiner
26-10-2012, 12:24
Sorry, bothering again - but it's really strange & crazy!
I did not change the stuff from yesterday, still in mind "IT WORKS" and this morning I was in a good mood and turned on the pc, ready for some type-in-hours. And what happened? All the same sh.. like yesterday. I stripped code down some more, real down to a minimum and I can point it out on one line of the script now.
Strange is, if I run it in Debug-Mode - it's all just fine. If I press F5 to run it: ERROR!
EDIT: Just ignore all that stuff written in italics below for the meantime, file behaves different now since I've uploaded and re-downloaded it, see "Edit:" and post below
Now check the script (attached), save it to the folder with sprite+sound-resources from yesterday
put your eyes on line 205 (first of UDT "a2dPointer, 'Pos as aPoint") - it should be commented out now,
just to check this:
line 228 which says "Dim Pointer as a2DPointer" is commented out also, so this UTD a2dPointer is not used in no case never ever!!!
run it,
press "F3" once (switch to Editor-mode)
press "esc" twice (switch back to Menu-mode and end)
program ends just fine, normal ok.
Now go to line 205 where you can read "Pos as aPoint", remove the comment-sign.
just look at the line below "Field as aPoint" is the same UDT,
(but leave that alone for now, I just want to show up, it's not the UDT "aPoint"'s fault)
run again
if YouGetNoErrorMessageNow then
--press "F3" once, "esc" twice, program should end then
--Get an Error-message thereafter? Run it again and see...
else
--check out what the message says, usually it complains something where the EditButtons get their SpriteID's
--but the line numbers in Error-Message mostly differ from run to run and these lines are ok.
endif
You do not get any Error at all? Then I'm gonna throw my pc into the garbage! Maybe it's because of 32Bit XP.
My Antivir in the meantime has the order to ignore everything that has to do with the thinBasic.exe
EDIT:
It's getting even more weird: I just downloaded this file myself to check if I uploaded the right one. I have it now twice on my PC, the old original "Stripped", and re-downloaded version "Stripped2".
Both consist of the same 17012 Bytes and behave different! The one I've up+downloaded crashes now instantly, the other one does not and behaves like written in italics above. These are the same files in every single byte! Does not matter if I open only one of them or if I have both in thinAir. I'm gonna reboot...
I have some problem with the Manage Attachments of this forum, I cannot delete any old file nor upload a new file. It works to upload but the file does not show up in list so I can not attach it. :(
ReneMiner
26-10-2012, 13:39
Please try that:
take the file from above, save it to the place where the resources (sprites+sounds) are.
Make sure it's called "Stripped.tbasic"
Open it in thinAir,
click into the code-window
press CTRL+A (mark all) then CTRL+C (copy to clipboard)
select File\New from thinAir-Menu
Paste (CTRL+V) that stuff into the new window and important SAVE AS "Stripped2.tbasic" to resource-path
run Stripped, (dunno if that matters, it has 8 chars before the extension of the name starts, or if it's the numeral in the end)
then run Stripped2....
if Stripped2 does not run, move on with the italics written stuff in post above using "stripped.tBasic"
PS. Have you read the latest issues in the lower right area of forum-front-page?
Petr Schreiber
26-10-2012, 16:27
Hi Rene,
I will check it. Sound like an issue with nonstandard characters in file maybe, stay tuned!
Petr
ReneMiner
26-10-2012, 16:37
I'm tuned in all time ;)
But just one remark:
Its not the numeral, I experimented already
it does not matter if I name it Stripped2 or StrippedX - it results the same on my computer. "Stripped" runs and behaves like described above,
with some extra-char in the end it does not.
Petr Schreiber
26-10-2012, 17:13
Very strange, both Stripped and Stripped2 run okay here :(
Fact is I test on Windows 7 and not Windows XP. Not sure if that can make difference.
PS. Have you read the latest issues in the lower right area of forum-front-page?
I think I did, what should I see here :)? I can see as last my reply to topic on >< operator
Petr
EDIT: I will try the thing mentioned in italics.
Petr Schreiber
26-10-2012, 17:22
Huh, I tried to do the things with line 205 and 228, still no error... strange.
I will try on Windows XP ASAP.
Petr
ReneMiner
26-10-2012, 17:26
then I guess it's about time for me to get a new computer...
you should see three, something like
"few typos..."-thread + "Variable-Tab next to explorer" (both in thinAir-Support Area)
and something about "code-tips" (thinAir General)
By the way, who is developing thinAir?
Petr Schreiber
26-10-2012, 19:20
The original developer for thinAIR was Roberto Biancchi, but since Roberto is not active here anymore, Eros re-wrote the thinAIR and now he is its developer.
Petr
ReneMiner
27-10-2012, 09:46
Good morning,
I'm still testing and trying out stuff. Today I just added one line to "stripped" before TB_Main() => TBGL_ResetKeyState()
Now it crashes also if a2DPointer.Pos is commented out. It just stops crashing if I comment out Field, Normal(5) and Busy(3) also.
I'm sure it has something to do with my UDT.
But the good news is thinBasic does not crash if I try any of the shipped samples.
I've already tried out a lot of them, they all work fine.
I'm just missing an example for Pointers+Memory since the help for Memory-Handling is very "undone".