It is currently April 26th, 2024, 8:20 am

Invalid substitute from URLs?

Get help with creating, editing & fixing problems with skins
hpgbproductions
Posts: 10
Joined: June 12th, 2018, 7:18 am

Invalid substitute from URLs?

Post by hpgbproductions »

Attempting to make something that involves converting an INI-formatted file to a substitution list. The user can type in a short command to open sites or programs. An example of such a file (original one is much longer):

Code: Select all

[ShortcutList]
chrome=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
yt=https:\\www.youtube.com\
y=http:\\yurucamp.jp
Lines starting with ; or [, or empty lines are removed by WebParser.
Eventually I get this which is an invalid Substitution:

Code: Select all

Substitute="chrome":"C:\\Program Files \(x86\)\\Google\\Chrome\\Application\\chrome\.exe","yt":"https:\\\\www\.youtube\.com\\","y":"http:\\\\yurucamp\.jp"
Anyone used long Substitution strings before? (or can see any issue?)
Code with the example list: https://drive.google.com/drive/folders/1NnAgAijXmDMMpgw-cgJl6zSzu7MxXRO7?usp=sharing
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Invalid substitute from URLs?

Post by balala »

hpgbproductions wrote: May 22nd, 2019, 5:07 pm Eventually I get this which is an invalid Substitution:
In this case in the Substitute option isn't needed to escape those characters with a backslash. Theoretically you could renounce to them: Substitute="chrome":"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe","yt":"https:\\www.youtube.com\","y":"http:\\yurucamp.jp"
But the problem is that the later strings will replace even the already replaced strings. To avoid this, you have to use regular expression substitution. Replace the Substitute option with the following one: Substitute="^chrome$":"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe","^y$":"http:\\yurucamp.jp","^yt$":"https:\\www.youtube.com\" and add a RegExpSubstitute=1 option as well.
hpgbproductions
Posts: 10
Joined: June 12th, 2018, 7:18 am

Re: Invalid substitute from URLs?

Post by hpgbproductions »

balala wrote: May 22nd, 2019, 6:19 pm In this case in the Substitute option isn't needed to escape those characters with a backslash. Theoretically you could renounce to them:
My main issue is that the Substitute string generated is invalid and rejected by the program. Testing with a hard-coded version has the same result.

Code: Select all

[program]
Measure=String
String=#mainstring#
RegExpSubstitute=1
Substitute=""^!chrome":"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe","^!yt":"https:\\www.youtube.com\","^!y":"http:\\yurucamp.jp""
DynamicVariables=1
Your suggested Substitute is also invalid for some reason.
Can't find any syntax issues like mismatched quotes.
(sorry for late reply, wasn't on forum)
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Invalid substitute from URLs?

Post by balala »

What you mean by
hpgbproductions wrote: May 24th, 2019, 3:24 pm the Substitute string generated is invalid and rejected by the program.
Especially what does mean the "rejected by the program"?
Could you please post the whole code?
hpgbproductions
Posts: 10
Joined: June 12th, 2018, 7:18 am

Re: Invalid substitute from URLs?

Post by hpgbproductions »

balala wrote: May 24th, 2019, 3:57 pm What you mean by

Especially what does mean the "rejected by the program"?
Could you please post the whole code?
Rejected as in the error message shows with every refresh.

Whole code was in the link in the original post since it's quite long. Here it is:

sclist2.inc (shortened substitution list using inc formatting) (test case)

Code: Select all

[ShortcutList]
; Lines starting with ";" or "[" act as comments and are ignored
; No quotes should be added
; Codes that contain other codes at the start must be defined first eg: !ab before !a
; Websites should contain a slash at the back for more reliability
; Some services are available as both an application and a website
; You may wish to change the shortcuts as needed.
chrome=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

yt=https:\\www.youtube.com\
y=http:\\yurucamp.jp
main.ini

Code: Select all

[Metadata]
Name=
Author=cmg-simplestuff//hpgbproductions
Version=1.0
License=
Information=Quickly launch applications and open files with short command codes.

[Rainmeter]
Update=1000
AccurateText=1
DynamicVariables=1

[Variables]
input=""

[UserNameMeasure]
Measure=Plugin
Plugin=SysInfo
SysInfoType=USER_NAME

[measure]
Measure=WebParser
URL=file://#CURRENTPATH#sclist2.inc
RegExp=(?si)(.*)
FinishAction=[!UpdateMeasure applysubdummy]

[compile]
Measure=WebParser
URL=[measure]
StringIndex=1
RegExpSubstitute=1
Substitute="(?m)^(\[|;).*$":"","[\r\n]+":",",",([^,]+)=([^,]+)":',"^!\1":"\2"',"^(,|\n)":"",",$":""
;          1                   2             3                                 4            5
OnUpdateAction=!SetOption program Substitute "[compile]"

[regexpdebug]
Meter=String
MeasureName=compile
SolidColor=ffffff
Text=%1
DynamicVariables=1

[Input]
Measure=Plugin
Plugin=InputText
Command1=[!SetVariable mainstring "$UserInput$"]
DefaultValue="Input"
X=10
Y=10
W=200
H=30
SolidColor=000000
FontColor=ffffff
FontFace=Montserrat
FontSize=16
DynamicVariables=1

[InputTextVisual]
Meter=String
X=10
Y=10
W=200
H=30
SolidColor=00000001
FontColor=ffffffbf
FontFace=Montserrat
FontSize=16
Text=Input
LeftMouseUpAction=[!CommandMeasure Input "ExecuteBatch ALL"]
DynamicVariables=1
AntiAlias=1

[program]
Measure=String
String=#mainstring#
RegExpSubstitute=1
Substitute=
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Invalid substitute from URLs?

Post by balala »

hpgbproductions wrote: May 24th, 2019, 4:29 pm Whole code was in the link in the original post since it's quite long.
Yep, indeed. Sorry, my mistake.
Ok, working on it. Let's see.