Textedit - textreplace doesn't work! Thread last updated on 2004-01-22 20:10:09

Posted by member 103440 on 2004-01-22 18:54:50

Hi! I'm driving nuts with this :(
I'm using textedit to change my theme flags, but i don't understand why it changes some flags and don't another’s. Here is the code:

script.rc
;------------------------------------------------------------------------------
; reload settings from disk and reload popup module
;------------------------------------------------------------------------------

*Script bang !RefreshSettings
*Script exec |Reload
*Script exec |ReloadModule "$ModulesDir$popup2-2.1.4.dll"
*Script ~bang

.........

;------------------------------------------------------------------------------
; bar icons script
;------------------------------------------------------------------------------

*Script bang !ToggleBarIcons
*Script gotoif ("$BarIconsOn$" = "true") BarIconsOn_lbl
*Script exec |textreplace @$ConfigDir$flags.rc@ @^(BarIconsOn *)false@ @\1true@
*Script exec |Reload
*Script exit
*Script label BarIconsOn_lbl
*Script exec |textreplace @$ConfigDir$flags.rc@ @^(BarIconsOn *)true@ @\1false@
*Script exec |Reload
*Script ~bang
;------------------------------------------------------------------------------
; big icons script
;------------------------------------------------------------------------------

*Script bang !ToggleBigIcons
*Script gotoif ("$BigButtonsOn$" = "true") BigButtonsOn_lbl
*Script exec |textreplace @$ConfigDir$flags.rc@ @^(BigButtonsOn *)false@ @\1true@
*Script exec |Reload
*Script exit
*Script label BigButtonsOn_lbl
*Script exec |textreplace @$ConfigDir$flags.rc@ @^(BigButtonsOn *)true@ @\1false@
*Script exec |Reload
*Script ~bang

;------------------------------------------------------------------------------
; sidebar script
;------------------------------------------------------------------------------

*Script bang !ToggleSidebar
*Script gotoif ("$BigButtonsOn$" = "true") SideOn_lbl [Here is my error instead of $BigButtonsOn$ should be $SideBarOn$ :(]
*Script exec |textreplace @$ConfigDir$flags.rc@ @^(SideBarOn *)false@ @\1true@
*Script exec |Reload
*Script exit
*Script label SideOn_lbl
*Script exec |textreplace @$ConfigDir$flags.rc@ @^(SideBarOn *)true@ @\1false@
*Script exec |Reload
*Script ~bang

;------------------------------------------------------------------------------
; Winamp Controls script
;------------------------------------------------------------------------------

*Script bang !ToggleWinampControls
*Script gotoif ("$AmpControlsOn$" = "true") AmpControlsOn_lbl
*Script exec |textreplace @$ConfigDir$flags.rc@ @^(AmpControlsOn *)false@ @\1true@
*Script exit
*Script label AmpControlsOn_lbl
*Script exec |textreplace @$ConfigDir$flags.rc@ @^(AmpControlsOn *)true@ @\1false@
*Script ~bang


flags.rc
;------------------------------------------------------------------------------
; flags for various theme options - do NOT edit by hand, use theme cfg. menu
;------------------------------------------------------------------------------

BarOnTop false
VWMOn true
BarIconsOn true
AmpControlsOn true
UseJamptoo false
BigButtonsOn false
SideBarOn true
MaximizeOverBar false
GesturesOn true
GesturesCommandsOn true


popuptheme.rc
;------------------------------------------------------------------------------
; theme config. popup menu (SHIFT+left click on desktop)
;------------------------------------------------------------------------------

*Popup "$ThemeName$" !New !PopupTheme

*Popup "tasks" !PopupTasks

*Popup !Separator
*Popup "BottomBar Options" Folder
IF BarIconsOn
*Popup "Disable Bar Icons" !execute [!ToggleBarIcons][!Recycle]
IF NOT BigButtonsOn
*Popup "Enable Big Icons" !execute [!ToggleBigIcons][!Recycle]
ELSE
*Popup "Disable Big Icons" !execute [!ToggleBigIcons][!Recycle]
ENDIF
ELSE
*Popup "Enable Bar Icons" !execute [!ToggleBarIcons][!Recycle]
ENDIF
*Popup ~Folder
*Popup "Sidebar Options" Folder
IF SideBarOn
*Popup "Disable SideBar" !execute [!ToggleSidebar][!Recycle]

IF AmpControlsOn
*Popup "Disable Winamp Controls" !execute [!ToggleWinampControls][!Recycle]
ELSE
*Popup "Enable Winamp Controls" !execute [!ToggleWinampControls][!Recycle]
ENDIF
ELSE
*Popup "Enable SideBar" !execute [!ToggleSidebar][!Recycle]
ENDIF
*Popup ~Folder
*Popup !Separator
*Popup "Edit themevars.rc" !execute ["$TxtEditor$" "$ConfigDir$themevars.rc"]
*Popup ~New


When i change the BarIconsOn flag it works just fine, and then when i try to change the SideBarOn flag it does nothing! (The same happens with AmpControlsOn). I don't understand because the code it's the same, i just changed the var/bangs names in the script.

And can someone please tell me why my script.rc file changes every time i use the scripts for changing the flags?

Posted by member 103440 on 2004-01-22 19:18:10 link

If i start with the SideBarOn flag in false and i use the !ToggleSidebar to change it to true, everything works fine, the sidebar appears, but once again if i try to change from true to false it does nothing. Do i have to do something about the modules when i try to disable the flags ?

Posted by member 12798 on 2004-01-22 19:26:01 link

ok, i'm currently not into the whole textreplace stuff, but evaluations with mzscript require %{} around the evar -> ("%{$BarIconsOn$}" = "true")

Posted by member 36955 on 2004-01-22 19:37:11 link

that shouldnt be true, since the items in flags.rc are just normal evars, not mzvars from what i can tell. what module versions are you using? and what do you mean by your script.rc file changing?

Posted by member 12798 on 2004-01-22 19:42:08 link

oh sorry, you're right ... just tried it

Posted by member 103440 on 2004-01-22 19:50:16 link

The modules i'm using are the following: mzscript-0.8.6l, textedit-2.52 . I have done more tests with my theme and i found this:
If the BigButtonsOn is False i can enable the SideBarOn, if the BigButtonsOn is True i can disable the SideBarOn. This doesn't make sense, in my theme those evars are completely independents!.
About the script.rc changing: i'm using Textpad to edit it, and when i use my theme popup to change the theme flags textpad warns me that script.rc has changed and if i want to reload it? I don't know why ?

Posted by member 103440 on 2004-01-22 20:10:09 link

Oh my god! i'm so dumb! i'm embaressed! :(
I have found the problem, i mismatched the code and forgot to change one var :( (i edited the post above to show the line).
Don't pay attention to this thread, problem solved ant it was my problem :(
Thanks for all your time. ;)