#193498 - 2009-04-17 08:00 PM
Re: Multiple Scripts and Parsing
[Re: crmsonknight]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
Using GOTO is bad on many levels. Lets say, for example, that I said "GOTO Post-109423" to get your answer. Where would you reply? That thread?, this original thread? or some other thread entirely?
GOSUB is a little bit better, and a good way to get used to functions. I could say "GOSUB Post-109423" to get more info, but when you're done reading that post, RETURN to the original post. GOSUB calls a SUBROUTINE by name that performs some task and returns to the original location (line following the gosub, actually). GOSUBs are OK, but you can't exchange data with them. They are part of the main program and have no isolation of variable names or data. Subroutines MODIFY THE ORIGINAL DATA.
Functions are the best because they provide a completely isolated environment - you can pass data to a function and it will get a COPY of the data. It can perform calculations and manipulate that data any way it wants without affecting the original data. You can return a COPY of the function's data back to the main program (where it can replace its copy with the modified data if you choose). Functions can also return result codes via EXIT, which can be checked by examining @ERROR, making it easy to tell if a function did its job successfully or not.
I'll post some code that will provide a few simple examples later this evening.. You should get the concept more clearly from those.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#193499 - 2009-04-17 08:07 PM
Re: Multiple Scripts and Parsing
[Re: Glenn Barnas]
|
crmsonknight
Fresh Scripter
Registered: 2009-03-20
Posts: 17
Loc: NH USA
|
Thank you I appreciate your time and input. This is what I'm trying to do.
If @USERID = "601Mgr_03" GOTO RM601C
endif
:RM6010
writevalue ("HKEY_CURRENT_USER\Environment", "Station", "601100", "REG_SZ")
writevalue ("HKEY_CURRENT_USER\Environment", "Extension", "601100", "REG_SZ")
writevalue ("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons", "1", "REG_SZ")
goto Common
:Common
writevalue ("HKEY_CURRENT_USER\Environment", "Formcache", "C:\Cache\cache%station%", "REG_SZ")
writevalue ("HKEY_CURRENT_USER\Environment", "Extension", %Ext%, "REG_SZ")
goto end
|
|
Top
|
|
|
|
#193501 - 2009-04-17 08:14 PM
Re: Multiple Scripts and Parsing
[Re: crmsonknight]
|
Gargoyle
MM club member
   
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Dependent on how many users that need custom settings...
Select
Case @UserID = "601MGR_03"
writevalue ("HKEY_CURRENT_USER\Environment", "Station", "601100", "REG_SZ")
writevalue ("HKEY_CURRENT_USER\Environment", "Extension", "601100", "REG_SZ")
writevalue ("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons", "1", "REG_SZ")
Case @UserID = "602MGR_01"
writevalue ("HKEY_CURRENT_USER\Environment", "Station", "601100", "REG_SZ")
writevalue ("HKEY_CURRENT_USER\Environment", "Extension", "601100", "REG_SZ")
writevalue ("HKEY_CURRENT_USER\Control
Case 1
;Maybe write to a log file or just do nothing
EndSelect
LoadCommon()
Function LoadCommon()
writevalue ("HKEY_CURRENT_USER\Environment", "Formcache", "C:\Cache\cache%station%", "REG_SZ")
writevalue ("HKEY_CURRENT_USER\Environment", "Extension", %Ext%, "REG_SZ")
$Function = @Error
EndFunction
Edited by Gargoyle (2009-04-17 08:15 PM) Edit Reason: bad copy/paste
_________________________
Today is the tomorrow you worried about yesterday.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 837 anonymous users online.
|
|
|