'Get token' question (Solved)

For questions about using Classic.

Post » Sat Jul 09, 2011 2:34 pm

How do i use 'Get token' to retrieve or isolate the end part of the following sentence -

C:\Documents and Settings\brobs\My Documents\My Pictures\Photo.png

So basically, i want (Photo.png)

I need a way that works regardless the length...for example :

C:\Documents and Settings\Photo.png   .....or

C:\My Documents \Photo.png

I know how to do when filling a list box,(using file object) but i can't
work out this way.

Thanks in advance.chrisbrobs2011-07-09 19:21:08
B
19
S
6
G
7
Posts: 1,205
Reputation: 7,298

Post » Sat Jul 09, 2011 2:51 pm

for the same drive you can use "/Photo.jpg" or "\Photo.jpg"shinkan2011-07-09 14:51:27
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Sat Jul 09, 2011 3:06 pm

[QUOTE=shinkan] for the same drive you can use "/Photo.jpg" or "\Photo.jpg"[/QUOTE]

I don't understand what you mean?

Sorry if im missing something obvious.

Were would it fit in the following:

GetToken(string, N [, delimiter])

Returns the Nth token in string using delimiter. The default delimiter is comma (,) if you do not specify your
own. Examples: GetToken("a,b,c", 2) gives "b", GetToken("one|two|three|four", 2, "|") gives "two"
B
19
S
6
G
7
Posts: 1,205
Reputation: 7,298

Post » Sat Jul 09, 2011 3:24 pm

There's "get token count" (NumTokens) expression. Use it to determine last index.
Ex:
GetToken(<string>, NumTokens(<string>, "\"), "\")DtrQ2011-07-09 15:26:41
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Sat Jul 09, 2011 4:06 pm

[QUOTE=DtrQ] There's "get token count" (NumTokens) expression. Use it to determine last index.
Ex:
GetToken(<string>, NumTokens(<string>, "\"), "\")[/QUOTE]

Thanks, it works.

For:
C:\Documents and Settings\brobs\My Documents\Construct1games\PHOTO.png

   + MouseKeyboard: On key Enter pressed
   -> Text2: Set text to GetToken(text1.Text, NumTokens(text1.Text, "\"), "\")


Gives: PHOTO.pngTom2011-07-09 16:14:14
B
19
S
6
G
7
Posts: 1,205
Reputation: 7,298


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests