Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, degenerate_762), 642 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to stop inchar? #344101
10/13/10 21:02
10/13/10 21:02
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
hopfel Offline OP
User
hopfel  Offline OP
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
Hey, I'm programming a little textbox using "inchar" (inkey doesn't make sense for that)
But my problem;
I have to stop the input with inchar, "inkey_active = 0;" doesnt work, don't have to explain why. laugh
Is there a possibility for that?

Thank you for help. ^-^


Hilf mir, dir zu helfen!
Re: How to stop inchar? [Re: hopfel] #344113
10/14/10 08:28
10/14/10 08:28
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Originally Posted By: hopfel
... "inkey_active = 0;" doesnt work, don't have to explain why. laugh ...

Yeah, you DO need to explain why... according to the manual it should work...

?!?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to stop inchar? [Re: EvilSOB] #344193
10/14/10 20:41
10/14/10 20:41
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
hopfel Offline OP
User
hopfel  Offline OP
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
It just works with inkey I guess.
It's just that I tried it out and then the engine crashes.
I looked at the manual too and there it just says,
inkey_active terminates the input with inkey...

Well, and that was just a reading-fail again. -.o'
So it looked clear for me, inkey_active isn't the right solution for that.
Well, but if you say, it should work with inkey_active,
then it's maybe another fault in my code and I'll try it out more exactly.
Thank you. laugh

Last edited by hopfel; 10/14/10 20:47. Reason: true stupidness.

Hilf mir, dir zu helfen!
Re: How to stop inchar? [Re: hopfel] #344217
10/15/10 08:36
10/15/10 08:36
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Heres a standalone script showing it in action. (formatting ugly UNTIL pasted into SED)

Run the script and then anything you type gets added to the text object by the "get_inchar()" function.
If you press 'Enter', the function will terminate itself and beep.

BUT, if you press 'F1', the function will terminate (and beep) via "inkey_active" being set to zero in main().

Code:
#include <acknex.h>
#include <default.c>

TEXT* buffer = { string( "Buffer = ");	font="Arial#18b";	flags=SHOW;	}


void get_inchar()
{
	STRING* tmp_str = str_create(" ");		char this_char = 0;
	while((this_char!=1)&&(this_char!=13))	// exit on "1" or "13"
	{													// 13 = pressed enter here
														// 1  = inchar terminated by main
		this_char = inchar(tmp_str);
		if(this_char!=1)   str_cat((buffer.pstring)[0], tmp_str);
		wait(1);   //This wait is !CRITICAL! or it wont react to inkey_active changes
	}
	beep();
}


function main()
{
 	get_inchar();		//start capturing keys into "buffer"

	while(1)
	{
		if(key_f1)		inkey_active = 0;		// terminating capture from
														// "outside" the inchar function
		wait(1);
	}
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to stop inchar? [Re: EvilSOB] #344234
10/15/10 11:57
10/15/10 11:57
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
hopfel Offline OP
User
hopfel  Offline OP
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
My code looks quiet exactly like your one, there are
just more then one of your function "get_inchar();"
running at the same time, because there are more then
one textbox I can write in. And then, it crashes.
BUT I went out, it works, when I put a wait(1);
BEFORE the inchar. I just don't know why. XD

So, this code crashes:

Click to reveal..
Code:
function inchar_fu()
{
while(1)
{if(inkey_active!=0)
inkey_active=0;

inchar(my_str);
wait(1);}}

function main()
{inchar_fu();
inchar_fu();
inchar_fu();}


And this does not:
Click to reveal..
Code:
function inchar_fu()
{
while(1)
{if(inkey_active!=0)
inkey_active=0;
wait(1);
inchar(my_str);
wait(1);}}

function main()
{inchar_fu();
inchar_fu();
inchar_fu();}


I invented this code, because I haven't my real test-code
on this Netbook, but it should be the same...

Jea, but it works and I'm happy. grin
Thank you EvilSOB for your help. ^-^


Hilf mir, dir zu helfen!
Re: How to stop inchar? [Re: hopfel] #344300
10/16/10 00:42
10/16/10 00:42
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
In my code, if you leave out the wait's then , in essence, only THAT function
is running and able to 'see' what keys are being pressed, and all other
functions are kind-of "on hold" whenever a key is pressed.

The wait in my example allows my get_inchar() to get a character,
and then it waits one frame, to allow other functions to see what key
has been pressed.


With your examples, niether will work 'well' because in both cases the multiple
instances will keep 'fighting' each other for control.
In the first example, the fighting is happening inside a single frame and causes the crash,
where in the second example they just 'take it in turns' to have control, not good methinks.


I need a better understanding your 'overall' project before I cant suggest anything further. PM me with it if you want it kept secret...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to stop inchar? [Re: EvilSOB] #344434
10/17/10 11:57
10/17/10 11:57
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
hopfel Offline OP
User
hopfel  Offline OP
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
Jea, this code above was just an example to show you what I mean, in my code all textboxes have a loop in it like:

while(Wait while I'm not active)wait(1);

There is just a collision with two inputs once, when I
"switch" to another textbox. Was it that, what you meant?

If not, I though my script for the contribution-forum,
so there is no problem with writing my project in here. grin
It's just a very big script, and I don't want to vaste to much of your time...

But if you can have a look on it, it'd be very nice. ^^
Here's the zip with the whole project:
http://ifile.it/95nbu71/Textfeld.zip
(sorry about ifile, I'm not at home and cant upload it on my server...
If I shall upload it on rapidshare or other platforms, just say)

Erm... Jea, the Commands etc. are on german, I couldn't translate it jet.
Hope that's no problem.
It's at least formatted to some degree and quite neat.

Thanks laugh


Hilf mir, dir zu helfen!

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