Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,388 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Adding mouse_left support for inkey #317531
04/01/10 06:15
04/01/10 06:15
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline OP
Expert
William  Offline OP
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
I'm currently using a function to stop inkey when I hit the left mouse button.

However, this does not properly store the string as it would if I hit enter or tab.

For example, if I were to type "ggg" and then end this prematurely:

str_cpy(gonline_uname," ");
result = inkey(gonline_uname); //- enter online name

The resulting string would be "ggg____________"

Whereas the underline is actual spaces(this forum wont let me display spaces there??). However, if I hit enter instead, it would be:

"ggg"

This would be fine if I could find a way to know how to trunc the spaces, but I do not. Could we have inkey_active = 0; act the same way as if we ended the inkey operation normally? Thanks.


Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/
Re: Adding mouse_left support for inkey [Re: William] #317574
04/01/10 11:23
04/01/10 11:23
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Seconded, i really need this too.

edit: for me the string always(!) has "spaces" at the end, even if the user presses enter.

Last edited by Rei_Ayanami; 04/01/10 11:28.
Re: Adding mouse_left support for inkey [Re: William] #317600
04/01/10 13:18
04/01/10 13:18
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
Maybe str_len() and str_trunc() would help you out in the meantime?


A8.3x Commercial, AcknexWrapper and VS 2010 Express
○pararealist now.
Re: Adding mouse_left support for inkey [Re: pararealist] #317622
04/01/10 14:54
04/01/10 14:54
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Or you can just trim off the end spaces.
Code:
int str_rtrim(STRING* input)
{	int trunc, pos;	for(pos=str_len(input)-1; pos>0; pos--)
	{	if((input.chars)[pos]!=32)
		{	str_trunc(input, (trunc=str_len(input)-pos-1));
			break;
	}	}
	return(trunc);
}

This function trims off any trailing spaces (on the right-hand end of the string),
and it returns the number of trimmed spaces if you want to know...



Last edited by EvilSOB; 04/01/10 21:21. Reason: clarified variable names

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Adding mouse_left support for inkey [Re: EvilSOB] #317691
04/01/10 20:44
04/01/10 20:44
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline OP
Expert
William  Offline OP
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
Wow, thanks for that snippet of code! I had tried using str_len and str_trunc to no avail, and I'm not really sure if I understand how your code does it, but it works. Thanks for the help guys. laugh

Re: Adding mouse_left support for inkey [Re: William] #317705
04/01/10 21:16
04/01/10 21:16
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Basically, it starts at the LAST character of the total string, and checks to see if it is a space(==32).
If it is NOT a space-character, it truncates everything 'beyond' this point, and exits the loop.
If it IS a space-character, it loops over to checks the next character back, et al.

note: variable "pos' is which byte it is currently checking,
and variable 'trunc' gets set to how many characters got truncated.

[EDIT] Ive just changed to snippet so the variable names are more descriptive...

Last edited by EvilSOB; 04/01/10 21:24.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Adding mouse_left support for inkey [Re: EvilSOB] #317728
04/02/10 01:00
04/02/10 01:00
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline OP
Expert
William  Offline OP
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
Hey thanks for the explanation! It was really helpful. laugh


Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/

Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | 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