Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Petra, AndrewAMD, Quad, VoroneTZ, 1 invisible), 488 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
inkey and key 'end' memory error #456366
11/20/15 12:09
11/20/15 12:09
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hi,

Normally I would ditch inkey and try to find another solution, but since this is a long project which already uses alot of inkeys, I am trying to make the best of it.

Anyway now to my problem: I personally never use the 'end' key when editing textboxes in programs/games, but I noticed that for inkey it gives memory errors (W1516) saying CAT.
My quess would be that is cause I do:
Code:
str_cat(input_str,"                         ");  
inkey(input_str);

to have more space to type. And it doesn't seem to give any problems whatsoever (for like the last 3 months of testing) besides when using 'end' key .
Is there anyway to disable the 'end' key or to prevent this memory error?

tia

Last edited by Reconnoiter; 11/20/15 12:10.
Re: inkey and key 'end' memory error [Re: Reconnoiter] #456367
11/20/15 13:13
11/20/15 13:13
Joined: Dec 2010
Posts: 224
NRW, Germany
NeoJones Offline
Member
NeoJones  Offline
Member

Joined: Dec 2010
Posts: 224
NRW, Germany
Puhh I dont know, sorry.


Errors are the engine of progress.

Version: A8 Commercial
OS: Win 7 64bit
Models: Cinema 4D
Re: inkey and key 'end' memory error [Re: NeoJones] #456368
11/20/15 13:20
11/20/15 13:20
Joined: Dec 2010
Posts: 224
NRW, Germany
NeoJones Offline
Member
NeoJones  Offline
Member

Joined: Dec 2010
Posts: 224
NRW, Germany
Mhh this dont helps?
Code:
if(!key_end)
{
inkey
...
}



Regards, NJ


Errors are the engine of progress.

Version: A8 Commercial
OS: Win 7 64bit
Models: Cinema 4D
Re: inkey and key 'end' memory error [Re: Reconnoiter] #456369
11/20/15 13:48
11/20/15 13:48
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
Originally Posted By: Reconnoiter

My quess would be that is cause I do:
Code:
str_cat(input_str,"                         ");  
inkey(input_str);

to have more space to type. And it doesn't seem to give any problems whatsoever (for like the last 3 months of testing) besides when using 'end' key .
Is there anyway to disable the 'end' key or to prevent this memory error?



dont understand why you are doing this .

Code:
//string off 255 spaces
	STRING* input=str_create("#255");
	inkey(input);
	while(1)
	{
		draw_text(input,0,0,COLOR_RED);
		wait(1);
	}



Compulsive compiler
Re: inkey and key 'end' memory error [Re: Wjbender] #456371
11/20/15 16:01
11/20/15 16:01
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
I always used inchar instead of inkey. Input can be checked and avoid whatever you want.

Code:
void fncModifyString ( STRING *str )
{
	char key[2];
	key[0] = NULL;
	key[1] = NULL;
	while ( 1 )
	{
		var nKey = inchar ( NULL );
		if ( nKey == 8 )
		{
			if ( !key[0] )
			{
				str_cpy ( str, "" );
				txtCursor->pos_x = panHscores->pos_x + MC_HIGHSCORE_BORDER_SIZE_X;
			}
			else
			{
				str_trunc ( str, 1 );
				txtCursor->pos_x = panHscores->pos_x + MC_HIGHSCORE_BORDER_SIZE_X + str_width ( str, fntHscores );
				int count = str_len ( str );
				while ( str_getchr ( str, count ) == 32 )
				{
					count -= 1;
					txtCursor->pos_x += str_width ( "t", fntHscores );
				} 
			}
		}
		else if ( nKey == 13 )
		{
			if ( str_len ( str ) == 0 )
				str_cpy ( str, MC_HIGHSCORE_NAME );
			break;
		}
		else if ( nKey == 27 )
		{
			str_cpy ( str, MC_HIGHSCORE_NAME );
			break;
		}
		else if ( str_len ( str ) > MC_HIGHSCORE_MAX_CHARS )
		{
			continue;
		}
		else if ( nKey < 32 )
		{
			continue;
		}
		else
		{
			if ( !key[0] )
			{
				str_cpy ( str, "" );
				txtCursor->pos_x = panHscores->pos_x + MC_HIGHSCORE_BORDER_SIZE_X;
			}
			key[0] = nKey;
			str_cat ( str, key );
			if ( nKey == 32 )
				txtCursor->pos_x += str_width ( "t", fntHscores );
			else
				txtCursor->pos_x += str_width ( key, fntHscores );
		}
	}
}


Re: inkey and key 'end' memory error [Re: txesmi] #456372
11/20/15 16:40
11/20/15 16:40
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
thanks guys I will try these things

Re: inkey and key 'end' memory error [Re: Reconnoiter] #456534
11/27/15 13:23
11/27/15 13:23
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Quote:
dont understand why you are doing this .

Code:

//string off 255 spaces
STRING* input=str_create("#255");
inkey(input);
while(1)
{
draw_text(input,0,0,COLOR_RED);
wait(1);
}
, how to get this working if you are using a global string?

globally initializing STRING* input_str = "#100"; doesnt work right when I am editing it with inkey and I have no extra space to write letters/numbers.

Re: inkey and key 'end' memory error [Re: Reconnoiter] #456540
11/27/15 18:22
11/27/15 18:22

M
Malice
Unregistered
Malice
Unregistered
M



in_key overwrites the string and can not exceed the string length. It's also a internal wait, I assume it can not draw_x till the internal wait is terminated. But I don't understand your issue. I'll put it on my testing list for later today, if you haven't solved it by then.

EDIT- You code works fine... As I believed, it draw text as soon as you hit (enter) the termination key. Due to the loop, only a TEXT* object can show the active entry of the inkey.
My test code
Code:
STRING* input_me="#228";

///////////////////////////////
function main()
{
  vec_set(screen_size,vector(800,400,0));
  vec_set(screen_color,vector(50,1,1)); // dark blue
  vec_set(sky_color,vector(50,1,1)); // dark blue
  video_window(NULL,NULL,0,"My New Game");
  inkey(input_me);
  while(1)
  {
  	draw_text(input_me,50,50,COLOR_WHITE);
  	wait(1);
}




Mal

Last edited by Malice; 11/27/15 18:40.
Re: inkey and key 'end' memory error [Re: Reconnoiter] #456542
11/27/15 18:46
11/27/15 18:46
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
Originally Posted By: Reconnoiter
Quote:
dont understand why you are doing this .

Code:

//string off 255 spaces
STRING* input=str_create("#255");
inkey(input);
while(1)
{
draw_text(input,0,0,COLOR_RED);
wait(1);
}
, how to get this working if you are using a global string?

globally initializing STRING* input_str = "#100"; doesnt work right when I am editing it with inkey and I have no extra space to write letters/numbers.


there's no need for global initialization .

Code:
//global level
STRING *glob_str;

//some function
void foo ()
{
     glob_str=str_create ("#100");
}



what I don't understand is when you write "extra space" , because if you initialize with #100 it means you have a string that can take 100 characters .

do you mean you want to write blank spaces in the string or do you mean you want to resize the string length?


Compulsive compiler
Re: inkey and key 'end' memory error [Re: ] #456543
11/27/15 18:49
11/27/15 18:49

M
Malice
Unregistered
Malice
Unregistered
M



I think your error from your first post is a access error. The internal loop and locking of the string.
Anyway use 2 strings , something like this...
Code:
STRING* str_ret="";
STRING* input_str="#256"

str_cat(str_ret,"                             ");
inkey(input_str);
str_cat(str_ret,input_str);
while(1)
{
 draw_text(str_ret,50,50,COLOR_WHITE);
wait(1);
}



Anyways I'm a bit confused and firing into the dark, so if I'm off track here. Sorry
Mal

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1