What's the purpose of each of the following. Why do I need more than one in a program, and in what order should they be called?
OpenScreen()
OpenWindow()
OpenWindowScreen()
OpenWindowedScreen()
OpenWindow3D()
Did I miss any? I got a response on another thread that indicated I need to InitKeyboard() and InitSprite() before any if these, and InitSprite() comes before all.
Most programs don't seem to close anything. They just reach an end and boom! It all stops. But you have CloseScreen(), CloseWindow(), CloseWindow3D(), and CloseProgram() options. Why aren't these used, and if needed, when? There seems to be no CloseWindowScreen() or CloseWindowedScreen(), so I guess these are somehow "lumped" together
The Search tool on these forums has just proved its worth. It is not case sensitive, and it gives you a contraction of what appears in each matched post. It shows order of things as others apply them. You can log into the forums more than once on different threads, do different searches, and uncover a surprising amount of undesclosed detail this way. For instance,by searching for initsprite(), I got over 3100 matches, and began to look down them:
. #PB_3DArchive_FileSystem) Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem) Parse3DScripts() InitSprite() InitKeyboard() InitMouse() OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0) CreateCamera(#camera, 0, 0, ...
... works without the debugger: Enumeration #material #camera #plane #cube1 #cylinder EndEnumeration #CameraSpeed = 0.1 InitEngine3D() InitSprite() InitKeyboard() InitMouse() ExamineDesktops() OpenWindow(0,0,0,DesktopWidth(0), DesktopHeight(0)," ..",#PB_Window_ScreenCentered) ...
.. #PB_3DArchive_FileSystem) Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem) Parse3DScripts() InitSprite() InitKeyboard() InitMouse() OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0) CreateCamera(#camera, 0, 0, ...
... #PB_3DArchive_FileSystem) Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem) Parse3DScripts() InitSprite() InitKeyboard() InitMouse() OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0) CreateMaterial(0, LoadTexture(0, ...
... values of x, y or z change. - Press space bar for a pulse - Esc for exit. Enumeration #Mainform EndEnumeration InitEngine3D() : InitKeyboard() : InitSprite() : InitMouse() OpenWindow(#Mainform,0,0, 1024, 768, "[PB 5.40 - ApplyEntityTorque", #PB_Window_SystemMenu) OpenWindowedScreen(WindowID(#Mainform),0,0,1024,768,0, ...
These are all interesting, but for different reasons. Several show where something can preceed InitSprite(), but the last one shows InitKeyboard() coming before InitSprite(), which is contrary to what I was told. Now just because it was coded that way, doesn't mean that it compiled and ran. This is just included code in a post somewhere. But the forum Search provides you a link back to the source (the title is actually a link), where you can do a Select All, copy the source code to the clipboard, open the PureBasic IDE (or actually any text editor), paste it, save it as a text file (with .pb extension) or compile it and test it.
What you have here is the perfect way of getting details about program construction you won't find anywhere else. Nothing is explained, but it is prepackaged example code. In most cases it should compile and run as-is, so you can see what it does. You can group it by the folders where you place it, for later reference or use. If it doesn't compile and run properly, because it was posted as problem code, the provided link takes you to the thread where it was likely solved.
Rather than search for the post and thread again. make a point of copying the link provided into the first (or last) line as a comment, behind a ";". while you are in the IDE or Editor. You can go back to the discussion or source anytime you want to by simply using the added link in the source code.
The problem with this is, it is simply not efficient. Here are the steps required:
Code: Select all
(1)  Pick a term of interest.  In this case, InitSprite()
(2) Login to PureBasic,fr/english
(3)  Enter the term into the search box.  Use Advance Search if more than one term is involved.
(4)  Pick through the results,  Do the following as a means to an end:
      a.  Click on a link with either mouse button,  Open a new tab, or contunue the present tab. 
      b.  Left-click on Select All.  Right-click and copy or Ctrl+C key combo.
      c.  Open a text editor or PureBasic IDE.  If the IDE, start a new file.
      d.  Using right-click and paste or Ctrl+V key combo, paste the selected source code into the
           text editor or IDE file.
      e.  Going back to the original tab or using the Back button, or simply doing a copy of the URL
          on the address box of the present tab, copy the link (URL) to the clipboard.
      f.  Return to the text editor or IDE.  Paste the Link/URL into the source code, top or bottom.
     g.  Put a ";" (semi-colon in front to make it a comment line.    
     h.  Now save it with a name and .pb extension.  You have to pick or make a folder where you
         want it to go (I named mine PBforums for starters).  For name, I began with pb0001.pb.
     i.  Either now or later, you will probably want to compile and run it, first to see if it will compile,
        and second, to see what it does.
I tried my first program, one involving Torque. The link is http://www.purebasic.fr/english/viewtop ... te#p470501
When I tried to compile and run it, it failed to compile. It's complaint was that CreateEntityBody was not a function, array, list, map or micro. And though it is capitalized like a keyword, changing it to all lower case showed that it was indeed not a keyword, since it did not adjust back as it had been automatically.
Now my first step, after manually changing it to lower case, something the IDE could have helped with if it gave you three choices concerning keywords:
(1) Change all keywords to UPPERCASE
(2) Change all keywords to lowercase
(3) Change all keywords to MixedCase (default)
If you picked (1) or (2), then went back to (3), and the word/term did not flip, it would be recognized immediately as not being a keyword. This would be a nice feature to have in the IDE
Okay, so what is CreateEntityBody()? The starting place to find out is to go back to the thread. And I have the link added to the source file. But now there is a problem: Unlike most email clients (which it's not one), the IDE does not recognize embedded URLs as a link to call up a web browser and go there. You have to copy the line (minus the ";") to the clipboard, open the browser yourself, select the address box, clear it (pr select all the contents), and do a paste, then hit the Enter key to go there. The job is made a little simpler if you use the Slimjet browser, as it allows you to open a new tab with nothing in the address box, or if something there then just click it once to do a select all, then the paste can be an immediate GO to that place. It's all in the settings.
What might be even better is for the PureBasic IDE to recognize ";http://" or ";https://" in source code as a link, so that when you right-click on it, it calls the default (or designated) browser and take you right there. But maybe that is just my opinion.
I went back to the forums, searched on createentitybody(, and the links indicate that it is related to beta tests for PB 5.40. In other words, it will be a feature add-in with a forthcoming release of the compiler. I didn't have to ask anybody, I just used Search and my noggin to unearth an answer.
Can't do that so well when picking among the possibilities with the Open* and Init* statements though. You can find what works, but as to why these choices and for what purpose, that has to either be in the documentation(?) or asked of experts (anybody that knows more than I do).


