Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, Ayumi), 773 guests, and 3 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
String functions with # #384809
10/08/11 18:48
10/08/11 18:48
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
I don't know if you consider the following as a bug or not, but for me it's either that or bad design and definately must be fixed!

"#n" is suppsed to create a string with n spaces. To create just a "#" at the beginning, I am supposed to write "##". That sounds not that bad in theory.

But now try running this code:
Code:
STRING* s1 = str_create("");
	STRING* s2 = str_create("");
	str_cpy(s1,"##"); // s1 is now "#"
	str_cpy(s2,s1); // s2 should be "#" but it's ""!
	error(s1);
	error(s2); // error ignores an emtpy error message
	error("end");


You will first get the "#" error message, the second is skipped because s2 is empty, then you get the "end" message.

When ever a string with a single "#" at the beginning is copied into an other string, it is being interpreted just like a char array that begins with a single "#". That makes it pretty much impossible tp work with strings that begin with a single "#", because you can't copy them!

In LBGUI, this has the effect, that you can't type in a # into an empty editbox. If it isn't empty, but the cursor is at the beginning, it's buggy.

So please change ALL string functions so that only in char arrays, not in STRINGs, "#n" is interpreted as n spaces, because "#n" is really only used inside a script to save space for strings with many spaces.

Re: String functions with # [Re: Lukas] #384897
10/10/11 07:38
10/10/11 07:38
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Thanks, we'll look into that. The '#n' makes not much sense anyway in lite-C.

Re: String functions with # [Re: jcl] #385745
10/23/11 10:03
10/23/11 10:03
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
I thought str_create(""); creates variable length strings anyway?
I've never used #n and hopefully didn't run into any problems due to pure memory luck...

Re: String functions with # [Re: FBL] #385767
10/23/11 17:02
10/23/11 17:02
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Well, in Lite-C strings have a variable length, but in C-Script, a string couldn't get longer than its original length. That's why the "#n" is there, so you can create long empty strings you can fill with text. Even in Lite-C, you still need to do that for inkey(). Frankly, I never used the "#n" either, because when I needed a string like this for inkey() I always just put in the spaces directly, because it didn't need to be so long that "#n" would ever be necessary.


Moderated by  jcl, Nems, Spirit, Tobias 

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