Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Well - My version looks like a novell, but being a function makes it a bit usefull.. BUT, not happy about how it goes thro the reg. Your versions doesn't lack error-checking tho - so I see no point in using a novell over a fewer lines of code...
REMINDER: These are My comments and they may not fully agree with other long term / old time scripters.
At this time if other Admins or Moderators or those with a good understanding of KiXtart want to comment please do, but don't post just to bump your post count.
And for those who want a Golfed down version here is an example.
Note though that for production scripts they should contain meaningful variable names and perform at least minimal error checking as well as some amount of documentation on what the script is doing.
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Using the IIF statement works if you understand the returns to put in. Since you are allowed to put in anything you want, an explanation of why 0 and 1 are used are in order I believe.
The primary reason for bringing this up is that I would have used -1 and 0, and that comes from using KiXforms.
Well I'm sure there are times when -1 is appropriate but in this case we're simply looking for a flag to show that we did not find the value so anything aside from 0 would indicate it was not found.
Comments for your 2nd solution similar to first with regards to using var names with meaning if used in larger script, though not the case here.
Good idea for splitting based upon Reg Type
Here is a method to remove the space from your output check.
I learned something new! I am a util kix scripter and always trying to find better ways of getting the task done. I was going with that we were to find if 'Enterprise Terminal Server' was present.
Code:
DIM $Round1Value $Round1Value = Split(ReadValue('HKCU\Software\Golfing', 'Round1'), '|') ? IIF(Trim(Join($Round1Value, ' ',UBound($Round1Value))) = 'Enterprise Terminal Server', 'Value Present', 'Value Not Present')
I like Learning Series better than Mini Golf. Following the principles of best coding practice can only improve beginners and intermediate scripters. I never had used IIF or Join in my production environment, but you know for sure I will review some of my scripts to see if they can be improved. You can teach an old dog new tricks. Good stuff!
Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Thank you Doc for this - It's really been a learing experience! I'll try to follow your feedback as much as I can! But to get back to our discussion we had eariler regarding my array's, could you or someone else care to share the real way to handle 'em?
Quote: I like Learning Series better than Mini Golf. Following the principles of best coding practice can only improve beginners and intermediate scripters. I never had used IIF or Join in my production environment, but you know for sure I will review some of my scripts to see if they can be improved. You can teach an old dog new tricks. Good stuff!