HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Post #2 of many
Internal Use Functions
Code:
####################################################
### INTERNAL USE ONLY FUNCTIONS ***
####################################################
Function DBSC_Str2ID(String IDS) {
Assert(Strlen(IDS)==4,RT_String("%sMust be 4 character string('%s')","DBSC_Str2ID: ",IDS))
Return(((RT_Ord(IDS,4)*256+RT_Ord(IDS,3))*256 + RT_Ord(IDS,2))*256) +RT_Ord(IDS,1)
}
Function DBSC_ColorSpaceIx(clip c) {
cs=c.IsRGB24?0:c.IsRGB32?1:c.IsYUY2?2:c.IsYV12?3:-1
return(cs>=0||VersionNumber<2.6)?cs:c.IsY8?4:c.IsYV16?5:c.IsYV24?6:c.IsYV411?7:-1
}
Function DBSC_InfoValidate(String InfoDB,Bool "MustExist",String "name") {
/*
DBSC_InfoValidate(), Returns InfoDB valid status True/False.
True return signifies that the InfoDB exists and is of type InfoDB.
If InfoDB does not exist and MustExist==True(Default), then throws error alert.
Name, allows display of client function name instead of this function name in error alerts.
*/
myName=Default(name,"DBSC_InfoValidate: ")
Assert(InfoDB!="",RT_String("%sMust provide an InfoDB filename",myName))
Valid = Exist(InfoDB)
GSCript("""
if(Valid) {
Valid = RT_DBaseFields(InfoDB)==7 && RT_VarIsSame(RT_DBaseGetID(InfoDB,0),DBSC_Str2ID("DBSC")) &&
\ RT_VarIsSame(RT_DBaseGetID(InfoDB,1),DBSC_Str2ID("INFO"))
if(!Valid) {
RT_DebugF("InfoDB failed Basic validation",name=myName)
!Valid?Assert(RT_DBaseGetID(InfoDB,1)!=DBSC_Str2ID("SCAN"),RT_String("%sWe Require the InfoDB, not the ScanDB",myName)):NOP
}
} Else {Assert(!Default(MustExist,True),RT_String("%sInfoDB does NOT exist\n'%s'",myName,InfoDB))}
""")
Return Valid
}
Function DBSC_ScanValidate(String ScanDB,Bool "MustExist",String "name") {
/*
DBSC_ScanValidate(), Returns ScanDB valid status True/False.
True return signifies that the ScanDB exists and is of type ScanDB.
If ScanDB does not exist and MustExist==True(Default), then throws error alert.
Name, allows display of client function name instead of this function name in error alerts.
No Check on whether ScanDB scene changes have been user overridden.
*/
myName=Default(name,"DBSC_ScanValidate: ")
Assert(ScanDB!="",RT_String("%sMust provide a ScanDB filename",myName))
Valid = Exist(ScanDB)
GSCript("""
if(Valid) {
Valid = RT_DBaseFields(ScanDB)==5 && RT_VarIsSame(RT_DBaseGetID(ScanDB,0),DBSC_Str2ID("DBSC")) &&
\ RT_VarIsSame(RT_DBaseGetID(ScanDB,1),DBSC_Str2ID("SCAN"))
if(!Valid) {
RT_DebugF("ScanDB failed Basic validation",name=myName)
!Valid?Assert(RT_DBaseGetID(ScanDB,1)!=DBSC_Str2ID("INFO"),RT_String("%sWe Require the ScanDB, not the InfoDB",myName)):NOP
}
} Else {Assert(!Default(MustExist,True),RT_String("%sScanDB does NOT exist\n'%s'",myName,ScanDB))}
""")
Return Valid
}
Function DBSC_QueryOveridden(String ScanDB) {
/*
DBSC_QueryOveridden(), Returns TOTAL number of Overides set on a ScanDB.
Uses third last RT_DBase attribute to store the number of user set Overrides (User attribute count currently 1024).
*/
myName="DBSC_QueryOveridden: "
Assert(DBSC_ScanValidate(ScanDB,MustExist=True,name=myName),RT_String("%sScanDB Invalid\n'%s'",myName,ScanDB))
nAttribs=RT_DBaseGetAttrib(ScanDB,-1)
Return RT_DBaseGetAttrib(ScanDB,nAttribs-4)
}
Last edited by StainlessS; 4th February 2015 at 07:49.
Reason: Update
|