Jump to content



Photo
- - - - -

Need a little help with for/next loops, and a couple other things.


  • Please log in to reply
2 replies to this topic

#1 WyldFox

WyldFox

    Neophyte

  • Members
  • Pip
  • 6 posts
  • Location:North Dakota

  • Flag: United States of America

  • Favorite Pinball: Williams Police Force

Posted 17 March 2011 - 10:12 AM

I have been using FP for a year or so now, off and on, and I am starting to make a more complex table. There are a couple of problems I keep running into and my programmer's sense is telling me that this is not right.

First of all is the For/Next loop. I know how they work but each time I put one in, the compiler would tell me that it expects and end of statement

ie:

Dim i

i = 0

For i = 1 to 10
Commands are ran....
Next I

This error usually does it for Next. What is going on with this?

The next question is the 'DoEvents' command. I just tried to use this as well to allow my DMD displays to update, but I get a 'This variable is undefined' message. I am using a scripting help guide that I did download off this site. Is there a command like this at all to allow me to update stuff while a Do/Loop is ran? If this is it, why would it do that?

The next is how do I make a basic add bonus to score type system when the player loses their ball? I tried many ways and still haven't figured it out. Some basic code will help, I learn by seeing then copy.

#2 Sebek74

Sebek74

    Enthusiast

  • Members
  • PipPipPip
  • 114 posts
  • Location:Lodz, Poland

  • Flag: Poland

  • Favorite Pinball: Pinball Dreams: Ignition

Posted 17 March 2011 - 12:42 PM

QUOTE (WyldFox @ Mar 17 2011, 01:12 PM) <{POST_SNAPBACK}>
I have been using FP for a year or so now, off and on, and I am starting to make a more complex table. There are a couple of problems I keep running into and my programmer's sense is telling me that this is not right.

First of all is the For/Next loop. I know how they work but each time I put one in, the compiler would tell me that it expects and end of statement

ie:

Dim i

i = 0

For i = 1 to 10
Commands are ran....
Next I

This error usually does it for Next. What is going on with this?


I suggest starting from here: http://www.w3schools...ipt_looping.asp
I believe the problem is caused by syntax - "next i" instead just "next". I remember that variable after next statement was required in 8-bit Atari basic smile.gif

QUOTE (WyldFox @ Mar 17 2011, 01:12 PM) <{POST_SNAPBACK}>
The next question is the 'DoEvents' command. I just tried to use this as well to allow my DMD displays to update, but I get a 'This variable is undefined' message. I am using a scripting help guide that I did download off this site. Is there a command like this at all to allow me to update stuff while a Do/Loop is ran? If this is it, why would it do that?

The next is how do I make a basic add bonus to score type system when the player loses their ball? I tried many ways and still haven't figured it out. Some basic code will help, I learn by seeing then copy.

Did you ever create event oriented software? The solution with "DoEvents" is good only in extremaly long loops in windows applications to refresh the window content. In Future Pinball you can forget about that solution. For such purposes you need to use timer. Here is the sample just from my head. That code will display counter from 10 to 0 in the middle of DMD 1 sec per step.

CODE
' MyTimer - timer object placed somewhere on the table
' MyDmd - DMD object
Sub SomeEventRoutine()
MyTimer.UserData = 10
MyTimer.Set TRUE, 1000
End Sub

Sub MyTimer_Expired()
MyDmd.Text = "[f1][yc][xc]" & MyTimer.UserData
MyTimer.UserData = MyTimer.UserData - 1
if MyTimer.Userdata = -1 then MyTimer.Enabled = FALSE
End Sub



Sebek74
Visit http://futurepinball.mm.com.pl/ for my tables download: Ignition, Beat-Box, Nightmare, Billion Dollar Gameshow, Wild West
http://futurepinball...om.pl/Gfx2DmdF/ for Gfx2DmdF font conversion
http://picasaweb.google.com/sebek74 - personal photo gallery

#3 WyldFox

WyldFox

    Neophyte

  • Members
  • Pip
  • 6 posts
  • Location:North Dakota

  • Flag: United States of America

  • Favorite Pinball: Williams Police Force

Posted 17 March 2011 - 06:47 PM

QUOTE (Sebek74 @ Mar 17 2011, 06:42 AM) <{POST_SNAPBACK}>
QUOTE (WyldFox @ Mar 17 2011, 01:12 PM) <{POST_SNAPBACK}>
I have been using FP for a year or so now, off and on, and I am starting to make a more complex table. There are a couple of problems I keep running into and my programmer's sense is telling me that this is not right.

First of all is the For/Next loop. I know how they work but each time I put one in, the compiler would tell me that it expects and end of statement

ie:

Dim i

i = 0

For i = 1 to 10
Commands are ran....
Next I

This error usually does it for Next. What is going on with this?


I suggest starting from here: http://www.w3schools...ipt_looping.asp
I believe the problem is caused by syntax - "next i" instead just "next". I remember that variable after next statement was required in 8-bit Atari basic smile.gif

QUOTE (WyldFox @ Mar 17 2011, 01:12 PM) <{POST_SNAPBACK}>
The next question is the 'DoEvents' command. I just tried to use this as well to allow my DMD displays to update, but I get a 'This variable is undefined' message. I am using a scripting help guide that I did download off this site. Is there a command like this at all to allow me to update stuff while a Do/Loop is ran? If this is it, why would it do that?

The next is how do I make a basic add bonus to score type system when the player loses their ball? I tried many ways and still haven't figured it out. Some basic code will help, I learn by seeing then copy.

Did you ever create event oriented software? The solution with "DoEvents" is good only in extremaly long loops in windows applications to refresh the window content. In Future Pinball you can forget about that solution. For such purposes you need to use timer. Here is the sample just from my head. That code will display counter from 10 to 0 in the middle of DMD 1 sec per step.

CODE
' MyTimer - timer object placed somewhere on the table
' MyDmd - DMD object
Sub SomeEventRoutine()
MyTimer.UserData = 10
MyTimer.Set TRUE, 1000
End Sub

Sub MyTimer_Expired()
MyDmd.Text = "[f1][yc][xc]" & MyTimer.UserData
MyTimer.UserData = MyTimer.UserData - 1
if MyTimer.Userdata = -1 then MyTimer.Enabled = FALSE
End Sub



Alright, thanks a lot, this will help me out some. I am used to basic GameMaker Language Linden Scripting Language and my first language I ever used was The original BASIC. The first two are event driven