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
3 registered members (AndrewAMD, TipmyPip, OptimusPrime), 15,359 guests, and 7 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
Page 2 of 2 1 2
Re: Facing new problem part II [Re: TripleX] #61535
03/19/06 23:52
03/19/06 23:52
Joined: Jul 2005
Posts: 366
eleroux Offline
Senior Member
eleroux  Offline
Senior Member

Joined: Jul 2005
Posts: 366
Quote:

1) this is actually not possible because of the build up of the TEXT object.
2) String arrays are always shown in the correct sort. Maybe check txt_setvisible / invisible

A small addition:
The first question can be realized with the new txt_create command:

Code:

var Txt_Array[20];
TEXT* txt_pointer;
//...
var a = 0;
while(a < 20)
{
Txt_Array[a] = handle(txt_create(1,1));
a += 1;
}

//...
txt_pointer = ptr_for_handle(Txt_Arrray[0]);
txt_pointer.font = font;




Triple-X




hey!

Can't get this to work. Does this work for you? It seems I can't use TEXT* because probably there are no such thing as a TEXT pointer.

At least the manual doesn't list TEXT* in the Pointers page, and all other keywords did work on this sample (STRING*, PANEL* etc)

If this is true, then... What the hack would I need txt_create() for, if I can't store its pointer?


Epatata: \n characters work for me in text strings.

Last edited by eleroux; 03/19/06 23:57.
Re: Facing new problem part II [Re: eleroux] #61536
03/24/06 20:18
03/24/06 20:18
Joined: Jul 2005
Posts: 366
eleroux Offline
Senior Member
eleroux  Offline
Senior Member

Joined: Jul 2005
Posts: 366
Epatata: Now I see what you mean. When you use functions like file_str_read or txt_load, "\n" are not converted to linefeeds. I have the same problem now.


I made a function and a little trick to help on this:


1) A search and replace function

Code:

STRING clipstr;
function searchAndReplace(str,searchstr,replacestr)
{
str_cpy(clipstr,str);
var foundat;
foundat = str_stri(clipstr,searchstr);

while(foundat)
{
str_trunc(str,str_len(clipstr)-foundat+1);
str_cat(str,replacestr);
str_clip(clipstr,foundat+str_len(searchstr)-1);
str_cat(str,clipstr);
foundat = str_stri(clipstr,searchstr);
}

}


Example:
mystring="could not read the file";
searchAndReplace(mystring,"read","LOAD");
//mystring now is: "could not LOAD the file";






2) The 'special characters' trick

Code:

// ...somewhere in your text loading function
file_str_read(mystring);
searchAndReplace(mystring,"\\n","\n"); //replaces "\n" with linefeeds in the string
text.string[0] = mystring;




Explanation: special characters are converted directly in C-Script. When you code:
STRING mystring = "Multi \n Line";
You are not putting a real '\n' in the string. The engine replaces the \n for a linefeed.

The same works inverse: if your text file contains "Multi \n Line", the engine doesn't see a linefeed, but a backslash and a 'n'. Thus, you must scan the text looking for a backslash and a 'n' and replacing that by a linefeed.

The special character for backslash is "\\".
So, if you search for "\\n" and replace it by "\n", you are asking "search the text for a backslash followed by 'n' and replace them by a linefeed".

Page 2 of 2 1 2

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