PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Amazing new feature in PPL!

It is now possible to assign a read and write function to variables. Everytime a variable value is read, PPL can call a user-defined function to validate the value and can also do the same when writing a value to a variable.

Here is a little demo demonstrating this cool new feature:
Code:
// Read write demo written by Alain Deschenes (c) ArianeSoft 2004

// You can do the same thing with object variables too!

func getm (Sender$, Value$, Address$)
return(Value$+1);
end;

func setm (Sender$, Value$, Address$)
if (Value$ > 1000)
Value$ = 1000;
end;
return (Value$);
end;

proc main
ReadWrite(m$, &getm;, &setm;);
m$ = 2000;
ShowMessage(m$); // Display 1001
end;
I just finished coding the REDIM() function, which will redimension any arrays already defined.
Kornalius,

You are making PPL have so many functions, soon we won't have to write ANY code! We'll just select the finished application from a drop down box!

+Database
-+Games
+-Adventure
+-Arcade
+-Card
++Puzzle
+-Tetris
...
..
..

+Zoology

Keep up the good work :D


EDIT:
Btw the comment in your code, shouldn't the value be 1000?
PointOfLight · 21 Oct 2004, 16:20 UTC
I'm sure he was just testing all of us to make sure we were paying attention.
No, 1001 is right.

m$ = 2000; // The variable becomes 1000 after the setm.

ShowMessage(m$); // You are getting the variable's value therefore getm is called at that point. So 1001 is right.

hehe, got ya all! :lol:
PointOfLight · 21 Oct 2004, 17:42 UTC
Oops. Didn't see the +1 in the getm statement, so I guess I really wasn't paying attention :oops:
I hate always being wrong :x
Here is a new feature that should have been added a long time ago but I didn't get a chance until now. The For loop statement.

From the help file:
for (sourcevar, start, end, increment)
Statement1
[break;]
[continue;]
end;

The for loop will loop from start to end assigning the new value to variable sourcevar every iteration of the loop. The increment value is added or suctracted from the variable sourcevar value every iteration of the loop.

Example:

for (i$, 4, 10, 1)
ShowMessage(i$);
end;

for (i$, 10, 4, 1)
ShowMessage(i$);
end;
PointOfLight · 22 Oct 2004, 13:13 UTC
For the millionth time, you are the man! That's something I've been wanting for quite some time now.
Kornalius,

Yes, the FOR loop is nice and a feature that was needed (yawn...), But ReadWrite I'd have to agree is amazing. 8O

How much does the use of this feature impact performance? Does heavy use of this feature have more of a performance hit than no use of this feature?

Brad
There is a performance loss for variables with a get or a set procedure, definitely. But if you don't use it, the speed is the same as before.
berwan03 · 25 Oct 2004, 07:40 UTC — amzing new features
Hello Kornalius,
Very good, was waiting a long time for the FOR loop.
The settet/getter is really good thing very usefull I'd have.
Good job