Get URL from inside text file

Get help using Construct 2

Post » Sat Sep 21, 2013 5:28 am

Hello,

I am trying to grab some text from a Steam URL shortcut. The URL file looks like this:

[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,0
[InternetShortcut]
URL=steam://rungameid/35450
IDList=
IconFile=E:\steam\steam\games\968db8c719c965fdc9ba37fe8dfabc0f7698c6fc.ico
IconIndex=0


I tried to get the text like this:

Set text => tokencount(Text.Text,4,"URL=")

But no luck.

How I can extract the URL on line 4 after the URL=?

Thanks in advance :)jojoe2013-09-21 05:29:31
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Sep 21, 2013 5:50 am

I think I am getting close. I tried this:

tokenat(Text.Text,2,"=")

And recieved :

steam://rungameid/35450
IDList

Is there any way I can saw the the "IDList" off the end? maybe tell it to stop at the new line somehow?
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Sep 21, 2013 6:43 am

Manual: Scroll down to text - lots of options
https://www.scirra.com/manual/126/system-expressions

I would learn and Use Regex - its a little confusing here is link to topic on regex
http://www.scirra.com/forum/how-to-use-regex_topic72722_page2.html

EDIT:
Regex Cheat Sheet - adding it here for my own benefit too :)
http://regexlib.com/CheatSheet.aspx?AspxAutoDetectCookieSupport=1


Forum seriously needs bookmark feature lolDUTOIT2013-09-21 06:45:44
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Sat Sep 21, 2013 7:16 am

DeleteDUTOIT2013-09-21 07:19:44
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Sat Sep 21, 2013 7:51 am

Hey thanks @DUTOIT!

Great cheat sheet and tutorials!

Here is what I came up with, It does not work though:

RegexMatchAt(Text.Text,"[^IDList=]$","^url=$\n"

B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Sep 21, 2013 9:18 am

This is what I had in mind. I am not that advanced with regex, but can use the replace - this should give you the url
RegexReplace(tokenat(Text.Text,2,"="), "/d", "g", "IDList")

Edit: it works
https://www.dropbox.com/s/qi1i15qeey3ksfs/demo-regex.capx

Edit2: Got your PM - You are most welcome. I personally prefer tokenat, but have started to use regex as it is available in C2 and is very powerful, but it is very complicated - well, at this point it is too me, with a bit of time things always get easier - ha haDUTOIT2013-09-21 10:04:25
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Sat Sep 21, 2013 5:10 pm

Yeah Thanks so much, Really nice of you to take the time and help people like this.

Your example will help me out quite a bit. I can see now that I had the syntax totally wrong.

The last expression you listed returned the exact same value to me. I am going to download the new C2 beta and look at your example as soon as I finish this clients application.

Luckily I have a workaround for my task of launching Steam or any other game. I will simply have the user drag and drop the shortcuts onto the node-webkit window, and the application will make a copy of the shortcut in a scratch folder in the users /home or %Documents% folder.

The kids are going to want to add custom images anyway for their icons, box art, and banners. There is no need for me to extract the icon or the Steam URL. I just thought it would look sharp if there was an icon or something in the box art placeholder right when they dragged and dropped the URL.

As soon as I have some more time to learn the in's and outs of RegEx I will offer them a free update.

This looks like a really powerful feature. I have always wondered how people made card and puzzle games.

It will make me a better Linux and Unix administrator too. I have put off learning GREP and Emacs for way too long.

Thanks again for leading me in the right direction @DOTOIT, This is going to answer some life-long questions about non-shooter games.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Sep 21, 2013 8:59 pm

I'm using it for card, boardgames, databases intensive apps right now lol

Steam thing sounds cool.

Anyways this is what it returns for me
steam://rungameid/35450
I hope that is what you are after. You could use regex and not the tokenat, but I am still figuring that out myself.
Sorry about saving in beta, I gave up with everyone else working in the beta and changed my steam to beta so I could get hold of C2 beta, anyways the debugger is fantastic. Worth the the upgrade.

No problem, hope it works out for you :)
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Mon Sep 23, 2013 1:04 am

This is the oddest thing.

The file you provided works like a charm, but my test file still returns a different value. (node-webkti)
https://www.dropbox.com/s/rscna3r3vda6n8e/getSTEAMline.capx

just drop a steam URL shortcut on the node-webkit window to load up the text.


I wonder if this is a bug?
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Mon Sep 23, 2013 1:24 pm

Yeah, node-webkit is problematic.
Where you getting the steam stuff from. You're capx is incomplete, can't get any data.

Thought) Could steam have changed the url structure - we checked for second = equal sign, could they have added another one in?

What are you getting?

But, it most probably is a bug.


Damn, I should read properly - just drop steam shortcut on window.
Wait let me try...DUTOIT2013-09-23 13:25:58
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Next

Return to How do I....?

Who is online

Users browsing this forum: TheCrazyPrince and 18 guests