Reply To: Split Function Problem

Home Forums Problems and solutions in GDL Object design Split Function Problem Reply To: Split Function Problem

#3985
Barry Kelly
Participant

If your storey name is “GF-Ground Floor” then you will find that “GF-Ground” is one part of the string and “Floor” is another.
So …

x = REQUEST (“Home_story”, “”, index, story_name)

n = SPLIT (story_name, "%s %s", split1, split2) 
IF n THEN
    text2 0, 0.5, story_name
    text2 0, 0, split1
    text2 0, -0.5, split2
ENDIF

What you actually need to do is search for the “-” character.
Assuming this is the same for all your storeys.
Then output the required number of characters.

pos = STRSTR (story_name, "-")
!    text2 0, 0, pos

prefix = STRSUB (story_name, 1, pos-1)
    text2 0, -2, prefix

Of course if the prefix is always 2 characters you know this already so you can just output the first 2 characters with STRSUB.

Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit