Need help with compilation............

BlitzPlus Forums/BlitzPlus Beginners Area/Need help with compilation............

Paul A. B.(Posted 2005) [#1]
I amde a program(pretty much useless, but its a start), and it runs fine while it is still not compiled and has debugging enabled. When I either turn debugging off or compile the code, it freezes. Can anyone help me out?? Thanks alot.

Here is the code:

Global Window_0
Global portnumber = 1


CreateWindow_Window_0()


Const EVNT_GADGET_ACTION= $401



Repeat Select WaitEvent(1)




Case EVNT_GADGET_ACTION



While portnumber < 65000
CreateTCPServer(portnumber)
portnumber = portnumber + 1

CreateLabel("Port being opened : " + portnumber, 95, 80, 192, 20, Window_0)
Wend
If portnumber = 65000
CreateLabel("All TCP ports have been opened, keep program on to keep ports up", 95, 80, 192, 30, Window_0)
End If







End Select

Forever
Function CreateWindow_Window_0 ()

Window_0 = CreateWindow( "Pauls Port Opener", 290, 210, 391, 354 ,Desktop(), 3 )
CreateLabel("Welcome to port opener v 1.1 . Just click the las button and all your ports will be opened!", 63, 47, 256, 200, Window_0)
CreateLabel("Made by Paul B", 95, 80, 192, 20, Window_0)

CreateButton("Click to begin port opening process", 78, 209, 224, 64, Window_0, 1)

End Function


WolRon(Posted 2005) [#2]
Why in the world are you creating 65000 labels that say ("Port being opened : " + portnumber)????

You only need one label. Just change it's text.


CS_TBL(Posted 2005) [#3]
*kuch* ... this reads like hell :)

read and learn :)

#1 -----------------------------------
when posting code here, use:

<code>
; your stuff here
</code>

and replace the < > with [ ] .. that'll keep the indenting.. (if any :)

#2 -----------------------------------

CreateButton(...) makes a button, but you can't use it directly since you didn't use the potential return handle..

bla=CreateButton(....) actually gives you 'bla' .. (which is an int value (4 bytes)) and 'bla' can now be used to use this button, change it's properties etc. etc.
This number is an adres.. don't do math with this number :) If you want to know which adres:
Notify bla
.. but it'll give you some number like 21375263 orso ..

Same for CreateLabel .. CreateWindow, CreatePanel etc. etc.

So, if you just do:
CreateButton(....)
then you can prolly use it by checking on EventID $401, but you can't specify which button one pressed, if you have more buttons (or other things that generate $401 events) at work..

#3 -----------------------------------

Keep it nicely structured, and don't cramp stuff together like "Repeat Select WaitEvent(1)"
It's not wrong to actually use lines :)

#4 -----------------------------------

Printing something to the screen, like QBasic did, is different in B+ .. don't use CreateLabel as a souped-up PRINT command :) If you want to use a label -which isn't strange in fact- then create 1 label, and change its caption each time it needs to show something different.
SetGadgetText gadgethandle,"blah" does that, iirc :)

#5 -----------------------------------

More like style .. but do you really want to type that whole EVNT_GADGET_ACTION terror again and again? :)
There's only a few often-used codes .. $803, $401, $201, $202, $203, $205, $206, $4001 are the ones I use most, and if I need more, I'll check the help. There's a bit of logic in some of the numbers..

on a canvas:
$201 mouse-down
$202 mouse-up
$203 mouse-move
$206 mouse-canvasrelease

Take this from me: code for 2 days with just those numbers, and you never need const-replacements ever again.


CS_TBL(Posted 2005) [#4]
#6 -----------------------------------

You created a function that creates a window.. that's fine, but there was no need to make that Window_0 a global. Just create the window inside that function and return the handle..


Something like
LazyCrap=CreateMYwindow()
Notify LazyCrap ; <- this will show some number like 2193674
End

Function CreateMYwindow()
  stinkyfart=CreateWindow("o_O",0,0,640,480)
  stinkylabel=CreateLabel("O_o",32,32,128,32,stinkyfart)
  Return stinkyfart
End Function

Function CreateMYwindow2() ; alternative way.. if you don't need to add stuff to the window..
  Return CreateWindow("^_^",0,0,640,480)
End Function


#7 -----------------------------------
http://www.blitzbasic.co.nz/Community/posts.php?topic=42793

;)

#8 -----------------------------------

You didn't make an exit in that app .. how do you want to quit it if you're not running debugmode? :)
typical uniform main-loop..
Repeat
  Waitevent()
  If EventID()=$803 quit=true ; $803 -> window-close button / alt-f4

  ; your stuff here..
  ;

Until quit
End