Posted By: pfeldman
SED Script Editor is crashing - 08/31/08 05:38
When I attempt to run the following program in debug mode, the SED Script Editor crashes ("Script Editor has encountered an error and needs to close.") There is undoubtedly something bad going on in this code, but the Script Editor should not crash.
#include <acknex.h>
#include <default.c>
var Mode= 0;
var t_1, t_2;
TEXT* user_txt= {
pos_x = 100; pos_y = 200;
font = "Arial#24bi";
flags= VISIBLE;
strings= 2;
}
// Player #1's displayed clock time:
TEXT* time_txt_1= {
pos_x = 100; pos_y = 300;
font = "Arial#60b";
flags= VISIBLE;
strings= 2;
}
// Player #2's displayed clock time:
TEXT* time_txt_2= {
pos_x = 450; pos_y = 300;
font = "Arial#60b";
flags= VISIBLE;
strings= 2;
}
function spacebar_press() {
switch(Mode) {
// Mode == 0 means that play has not yet started, so start it now:
case 0:
Mode= 1;
// Update help text:
str_cpy( (user_txt.pstring)[0], "Press spacebar to switch clocks.");
break;
// Mode == 1 means that it is player #1's turn and that the game is
// not currently paused:
case 1:
// Update displayed time on screen:
str_cpy( (time_txt_1.pstring)[0], "Player 1: ");
str_cpy( (time_txt_1.pstring)[1], "");
str_cat_num( (time_txt_1.pstring)[1], "%0.1f", t_1);
Mode= 2;
break;
// Mode == 2 means that it is player #2's turn and that the game is
// not currently paused:
case 2:
// Update displayed time on screen:
str_cpy( (time_txt_2.pstring)[0], "Player 2: ");
str_cpy( (time_txt_2.pstring)[1], "");
str_cat_num( (time_txt_2.pstring)[1], "%0.1f", t_2);
Mode= 1;
break;
}
}
// ------------------------------------------------------------------------
function main() {
video_mode = 7; // create a program window of 800x600 pixels
screen_color.blue = 50; // and make its background dark blue
str_cpy( (user_txt.pstring)[0],
"Enter initial time in minutes (default= 10): ");
// Wait for user to type something (or nothing) followed by Enter:
inkey((user_txt.pstring)[1]);
// Convert user input string to a number and convert number to seconds:
t_2= t_1= 60 * str_to_num((user_txt.pstring)[1]);
if (t_1 <= 0) {
t_2= t_1= 600; // Assign default value.
}
// Display initial times:
str_cpy( (time_txt_1.pstring)[0], "Player 1: ");
str_cpy( (time_txt_1.pstring)[1], "");
str_cat_num( (time_txt_1.pstring)[1], "%0.1f", t_1);
str_cpy( (time_txt_2.pstring)[0], "Player 2: ");
str_cpy( (time_txt_2.pstring)[1], "");
str_cat_num( (time_txt_2.pstring)[1], "%0.1f", t_2);
// Display initial help text:
str_cpy( (user_txt.pstring)[0], "Press spacebar to start clock #1.");
on_space= spacebar_press;
while (1) {
// Wait for half a second:
wait(-0.5);
// Player #1's turn:
if (Mode == 1) {
// Decrement player #1's time:
t_1-= 0.5;
// Update displayed time on screen:
str_cpy( (time_txt_1.pstring)[0], "Player 1: ");
str_cpy( (time_txt_1.pstring)[1], "");
str_cat_num( (time_txt_1.pstring)[1], "%0.1f", t_1);
// If out of time, terminate the program:
if (t_1 <= 0) break;
}
// Player #2's turn:
if (Mode == 2) {
// Decrement player #2's time:
t_2-= 0.5;
// Update displayed time on screen:
str_cpy( (time_txt_2.pstring)[0], "Player 2: ");
str_cpy( (time_txt_2.pstring)[1], "");
str_cat_num( (time_txt_2.pstring)[1], "%0.1f", t_2);
// If out of time, terminate the program:
if (t_2 <= 0) break;
}
}
}
#include <acknex.h>
#include <default.c>
var Mode= 0;
var t_1, t_2;
TEXT* user_txt= {
pos_x = 100; pos_y = 200;
font = "Arial#24bi";
flags= VISIBLE;
strings= 2;
}
// Player #1's displayed clock time:
TEXT* time_txt_1= {
pos_x = 100; pos_y = 300;
font = "Arial#60b";
flags= VISIBLE;
strings= 2;
}
// Player #2's displayed clock time:
TEXT* time_txt_2= {
pos_x = 450; pos_y = 300;
font = "Arial#60b";
flags= VISIBLE;
strings= 2;
}
function spacebar_press() {
switch(Mode) {
// Mode == 0 means that play has not yet started, so start it now:
case 0:
Mode= 1;
// Update help text:
str_cpy( (user_txt.pstring)[0], "Press spacebar to switch clocks.");
break;
// Mode == 1 means that it is player #1's turn and that the game is
// not currently paused:
case 1:
// Update displayed time on screen:
str_cpy( (time_txt_1.pstring)[0], "Player 1: ");
str_cpy( (time_txt_1.pstring)[1], "");
str_cat_num( (time_txt_1.pstring)[1], "%0.1f", t_1);
Mode= 2;
break;
// Mode == 2 means that it is player #2's turn and that the game is
// not currently paused:
case 2:
// Update displayed time on screen:
str_cpy( (time_txt_2.pstring)[0], "Player 2: ");
str_cpy( (time_txt_2.pstring)[1], "");
str_cat_num( (time_txt_2.pstring)[1], "%0.1f", t_2);
Mode= 1;
break;
}
}
// ------------------------------------------------------------------------
function main() {
video_mode = 7; // create a program window of 800x600 pixels
screen_color.blue = 50; // and make its background dark blue
str_cpy( (user_txt.pstring)[0],
"Enter initial time in minutes (default= 10): ");
// Wait for user to type something (or nothing) followed by Enter:
inkey((user_txt.pstring)[1]);
// Convert user input string to a number and convert number to seconds:
t_2= t_1= 60 * str_to_num((user_txt.pstring)[1]);
if (t_1 <= 0) {
t_2= t_1= 600; // Assign default value.
}
// Display initial times:
str_cpy( (time_txt_1.pstring)[0], "Player 1: ");
str_cpy( (time_txt_1.pstring)[1], "");
str_cat_num( (time_txt_1.pstring)[1], "%0.1f", t_1);
str_cpy( (time_txt_2.pstring)[0], "Player 2: ");
str_cpy( (time_txt_2.pstring)[1], "");
str_cat_num( (time_txt_2.pstring)[1], "%0.1f", t_2);
// Display initial help text:
str_cpy( (user_txt.pstring)[0], "Press spacebar to start clock #1.");
on_space= spacebar_press;
while (1) {
// Wait for half a second:
wait(-0.5);
// Player #1's turn:
if (Mode == 1) {
// Decrement player #1's time:
t_1-= 0.5;
// Update displayed time on screen:
str_cpy( (time_txt_1.pstring)[0], "Player 1: ");
str_cpy( (time_txt_1.pstring)[1], "");
str_cat_num( (time_txt_1.pstring)[1], "%0.1f", t_1);
// If out of time, terminate the program:
if (t_1 <= 0) break;
}
// Player #2's turn:
if (Mode == 2) {
// Decrement player #2's time:
t_2-= 0.5;
// Update displayed time on screen:
str_cpy( (time_txt_2.pstring)[0], "Player 2: ");
str_cpy( (time_txt_2.pstring)[1], "");
str_cat_num( (time_txt_2.pstring)[1], "%0.1f", t_2);
// If out of time, terminate the program:
if (t_2 <= 0) break;
}
}
}