Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Windows version 1.0.4 released
This is just a minor bug fix.


Objects can now properly be assigned to object array references in functions. Earlier, a function like the one below would cause a runtime error:

procedure assign(&objects?[], object?)
  objects[0] = object

For some reason, the system command did absolutely nothing on Windows (although the undocumented shellexecute did), but it's functioning now.

system "dir & echo hello world & pause"

If you want to capture the output, I suggest you pipe it to a file and read it from there for now:

' Get a list of files in the current directory.
system "dir /b > temp.txt"
open file 0, "temp.txt"


set mouse <x>, <y> was a bit bugged but has been fixed now. After calling the command, the mousex() and mousey() functions would return incorrect values until the user moved the mouse and new coordinates were registered.
(03-24-2019, 12:31 AM)Rick3137 Wrote: Nice fix.

 My computer made me take out the previous version before I could use it.

 Some kind of name conflict.

 The system command opens up a whole new bunch of experiments. For instance it is possible to use the command line while the NaaLaa program is running.

System "cmd"

very cool.

Yeah, the system command is the easy way. But if you need to do stuff in the background, without having a console window popup, you can use the shellexecute command. 

For example, if you want to execute "dir /b *.png > png_files.txt" to put a list of all png files in the current directory into a file png_files.txt (/b strips all information but the actual file names), you could call:

shellexecute "open", "cmd", "", "/c dir /b *.png > png_files.txt", true

And if you want to create a new folder named doop:

shellexecute "open", "cmd", "", "/c mkdir doop", true

I believe the syntax is:

shellexecute <operation>, <file>, <directory>, <parameters>, <wait_until_operation_is_done>

But I'm not quite sure, and I don't have the information available at this moment. It's used in NED to launch the compiler, and that's the only reason the command was added, haha Smile

I have no idea of why the system command hasn't been working for a long time. The C code had actually been commented out, maybe by mistake, who knows. Because I remember using it when dealing with FTP stuff in a naalaa program many years ago.
I made a small change, fixed a problem with set mouse and updated the installer without changing the version number.
Yeah, I have to uninstall the old version every time too Sad I'm using some program to generate the installers. Even though only two files have changed and I set it up for patching, the behavior is the same. I must be doing something wrong.
Great news, thanks for the info and update.
Yo marcus

and where is download link?
(04-24-2019, 01:21 PM)Rick3137 Wrote: Hello Marcus:

  While you are still working on key board functions, there are a few that would help for making games. I have been spinning my wheels for several weeks on a game that could use these.

 OnKeyUp( 37 )
 OnKeyDown( 39 )

 I would like to run a procedure when a key is pressed, or released.

NaaLaa does not have a built in "callback" system or "function pointers", so these things can't easily be added.

If you're just interested in using it for a few keys you can get around it with code like this:

import "Keycodes.lib"
 if keydown(VK_SPACE)
  if not spacebarPressed
   spacebarPressed = true
   wln "Spacebar pressed"
  if spacebarPressed
   spacebarPressed = false
   wln "Spacebar released"
 wait 16
until keydown(VK_ESC)
I wrote a more generic version of the code above. You have to register the keys you want to listen to with RegisterKey, and then call HandleKeys in your program loop. HandleKeys will call KeyDown and KeyUp if the status changes for any of the keys you've registered.

import "Keycodes.lib"



' Called when a key is pressed.
procedure KeyDown(key)
    wln "Key ", key, " pressed"

' Called when a key is released.
procedure KeyUp(key)
    wln "Key ", key, " released"

' Listen for VK_SPACE, VK_LEFT and VK_A
_RegisterKey VK_SPACE
_RegisterKey VK_LEFT
_RegisterKey VK_A

' Loop.

    wait 16

' Register a key that you want events for.
procedure RegisterKey(key)
    vRegisteredKeys[vRegisteredKeyCount] = key
    vRegisteredKeyCount = vRegisteredKeyCount + 1

' Call once per tick in your game loop.
procedure HandleKeys()
    if vRegisteredKeyCount > 0
        for i = 0 to vRegisteredKeyCount - 1
            if keydown(vRegisteredKeys[i])
                if not vKeyStatus[vRegisteredKeys[i]]
                    vKeyStatus[vRegisteredKeys[i]] = true
                    _KeyDown vRegisteredKeys[i]
                if vKeyStatus[vRegisteredKeys[i]]
                    vKeyStatus[vRegisteredKeys[i]] = false
                    _KeyUp vRegisteredKeys[i]

Hope it helps Smile

Note, that if you pause your program with wait, wait keydown or wait mousebutton the KeyDown and KeyUp functions won't be triggered until the next time you call HandleKeys. If you need to get around this, I suggest you write your own versions of these commands that use loops. Example:

' Wait with key events.
procedure Wait(ms)
    t = time() + ms
        wait 1
    until time() >= t
Hello Marcus,

There will be a new version of NAALAA in the next months ? (I hope)

Your language need more advertising, it is great....

I want the same NAALAA with an optimized IDE (no lines limit) Smile

Forum Jump:

Users browsing this thread: 1 Guest(s)