Page 1 of 1 1
Topic Options
#81791 - 2003-08-13 05:55 PM Defining custom macro
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Sometimes we have some variables that we define and use as macros, for example:
$os = split(@ProductType)[1]
$csd = val(right(@csd,1))
$admin = ingroup('@wksta\'+sidtoname('S-1-5-32-544'))-1+@INWIN

I'd like it if a variable could be defined as 'read only'... something like the SET command...

hmmm. perhaps that would be the simplest way to go.
setl('csd = val(right(@csd,1))')
? %csd%
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81792 - 2003-08-13 06:00 PM Re: Defining custom macro
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I think what you actually want is
code:
const $var='constant value'

IIRC, it has been proposed some time ago.
_________________________
There are two types of vessels, submarines and targets.

Top
#81793 - 2003-08-13 06:04 PM Re: Defining custom macro
Wizard Offline
Hey THIS is FUN
*****

Registered: 2000-12-05
Posts: 264
Loc: Bristol, England
CONST would be a good idea as it fits with other programming languages.

Also, you could define another file full of CONSTs to use like we do with UDFs.

Wiz
_________________________
Wizard
There's no place like 127.0.0.1

vb | kix | batch | html | cfm | js | english

Top
#81794 - 2003-08-13 06:05 PM Re: Defining custom macro
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Like this? InitKFConstants() - Initializes KiXforms constants
_________________________
There are two types of vessels, submarines and targets.

Top
#81795 - 2003-08-13 06:15 PM Re: Defining custom macro
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
then this would be good for the Standards FAQ

Cool
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81796 - 2003-08-13 06:23 PM Re: Defining custom macro
Wizard Offline
Hey THIS is FUN
*****

Registered: 2000-12-05
Posts: 264
Loc: Bristol, England
Jens, thats the one.!
_________________________
Wizard
There's no place like 127.0.0.1

vb | kix | batch | html | cfm | js | english

Top
#81797 - 2003-08-15 04:32 PM Re: Defining custom macro
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Rad,

Are there any others that need to be included?

Jens refers to the one used for KixForms. We don't need that extensive of one for regular KiXtart, correct?

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#81798 - 2003-08-15 05:11 PM Re: Defining custom macro
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
dunno... did you get the one for $desktop and $startmenu

I use these all the time:
$HKLMSMWCV
$HKCUSMWCV
$HKLMSMWNTCV
$HKCUSMWNTCV

for AD I like:
$oRootDSE = GetObject("LDAP://rootDSE")
$oDefautNamingContext = $oRootDSE.Get("defaultNamingContext")
$oRootDSE = 0
$ldap="LDAP://"+@domain+"/"+$oDefautNamingContext

code:
   	$nul         =SpecialFolder("Desktop StartMenu Favorites AllUsersDesktop AllUsersStartMenu")

;****************************************************************************************************
Function SpecialFolder($folders)
Dim $sAllFolders, $objWshShell, $Folder, $nul
$sAllFolders= "AllUsersDesktop AllUsersStartMenu AllUsersPrograms AllUsersStartup AppData Desktop Favorites "+
"Fonts MyDocuments NetHood PrintHood Programs Recent SendTo StartMenu Startup Templates"
$objWshShell = CreateObject("WScript.Shell")
If @ERROR Exit(1) EndIf
For Each $Folder in Split($Folders)
if instr($folder, $sAllFolders)
$nul=Execute("global $$folder")
$nul=Execute("$"+$Folder+" = $$objWshShell.SpecialFolders($$Folder)")
endif
Next
$objWshShell=''
EndFunction



[ 15. August 2003, 17:12: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81799 - 2003-08-15 05:14 PM Re: Defining custom macro
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, for AD you actually use:
code:
$oDefautNamingContext = GetObject("LDAP://rootDSE").Get("defaultNamingContext")
$ldap="LDAP://"+@domain+"/"+$oDefautNamingContext

_________________________
!

download KiXnet

Top
#81800 - 2003-08-15 05:20 PM Re: Defining custom macro
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
this works also...

$ldap="LDAP://"+@domain+"/"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81801 - 2003-08-15 05:41 PM Re: Defining custom macro
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
code:
 
$OS = split(@ProductType)[1]
$CSD = val(right(@csd,1))
$ADMIN = ingroup('@wksta\'+sidtoname('S-1-5-32-544'))-1+@INWIN
$HKLMSCCS ="HKLM\SYSTEM\CurrentControlSet"
$HKCUSMWCV ="HKCU\Software\Microsoft\Windows\CurrentVersion"
$HKLMSMWCV ="HKLM\Software\Microsoft\Windows\CurrentVersion"
$HKLMSMWNTCV ="HKLM\Software\Microsoft\Windows NT\CurrentVersion"
$HKCUSMWNTCV ="HKCU\Software\Microsoft\Windows NT\CurrentVersion"
$Desktop =readvalue($HKCUSMWCV+"\Explorer\Shell Folders",'Desktop')
$StartMenu =readvalue($HKCUSMWCV+"\Explorer\Shell Folders",'StartMenu')
$Favorites =readvalue($HKCUSMWCV+"\Explorer\Shell Folders",'Favorites')
$MyDocuments =readvalue($HKCUSMWCV+"\Explorer\Shell Folders",'MyDocuments')
$alldesktop =expandenvironmentvars(readvalue($HKLMSMWCV+"\Explorer\User Shell Folders","Common Desktop"))
$allstartmenu=expandenvironmentvars(readvalue($HKLMSMWCV+"\Explorer\User Shell Folders","Common Start Menu"))
$LDAP ="LDAP://"+@domain+"/"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")



[ 15. August 2003, 17:53: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81802 - 2003-08-15 06:29 PM Re: Defining custom macro
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
rad, wasn't looking for working solution.
just realized that you used one var for nothing as you immediately flushed it.
_________________________
!

download KiXnet

Top
#81803 - 2003-08-15 09:59 PM Re: Defining custom macro
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Added to BKM FAQ.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 661 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.068 seconds in which 0.03 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org