GML only part of a string...

A

Anomaly

Guest
you know in file searching you can say... search: thisFile10_*.* and it will find any thing that begins with just "thisFile10_"
is there a way to phrase strings in GM to achieve something similar?
 
A

Anomaly

Guest
Oh whoops
Sorry I wasn't clear as to what I meant exactly...
I meant in strings but NOT for files..

Like var layervar = string "parallax_layer_1" + " * "
Where * would be anything...
And if I only have one thing that begins with " paralax_layer_1 "..it would use that.
 

Homunculus

Member
You can use string copy with the size of the string you are looking for. Example:

Code:
var starts_with = "parallax_layer_1";
var count = string_length(starts_with);

var str = string_copy(layervar,1,count);

if(str == starts_with) {..do something..}
Ideally you could turn this into a script so all you have to do is something like string_starts_with(layervar,"parallax_layer_1");
 
A

Anomaly

Guest
isn't there something where .. if "this" character in the string is the actual character "1" or "2" then so and so...
was trying to find that command...
 
string_pos() function is the closest to what you want.

Code:
var string_to_check = "thisFile10_abcdefg"
var result = string_pos("thisFile10_", string_to_check)
"result" will equal 0 if no matching string is found, or it will return the position the string begins at if it finds a match.

So in the above code example, result will be 1. (strings start at position 1 in GMS)

Manual : string_pos()
 
Top