I have script to display CHMOD for ftp files.
Each time I change folder, I have this error...
mer. 18/12/2024 10:32:58 Colonne_CHMOD: Erreur à la ligne 24, position 2
mer. 18/12/2024 10:32:58 Colonne_CHMOD: Objet requis: 'scriptColData.tab' (0x800a01a8)
Can you help me please
option explicit
Function OnInit(initData)
initData.name = "Colonne_CHMOD"
initData.desc = "Ajoute une colonne 'CHMOD' pour afficher les permissions FTP."
initData.copyright = "2016 Albator V (Michiels Thomas)"
initData.min_version = "12.0.7"
initData.version = "1.0"
InitData.group = "Colonne"
initData.default_enable = True
End Function
Function OnAddColumns(addColData)
Dim col: Set col = addColData.AddColumn
col.name = "CHMOD"
col.method = "OnCHMOD"
col.autorefresh = 2
col.justify = "center"
End Function
Function OnCHMOD(scriptColData)
Dim CHMOD, i
If Left(scriptColData.tab.path, 6) = "ftp://" And Len(Trim(scriptColData.item.attr_text)) = 10 Then
CHMOD = Trim(scriptColData.item.attr_text)
' remplace les lettres par des 1
For i = 1 to Len(CHMOD)
If Mid(CHMOD, i, 1) <> "-" Then CHMOD = Replace(CHMOD, Mid(CHMOD, i, 1), 1)
Next
' remplace les tirets par des 0
CHMOD = Replace (CHMOD, "-", 0)
' conversion en binaire
CHMOD = BinaryToDecimal(Mid(CHMOD, 2, 3)) & BinaryToDecimal(Mid(CHMOD, 5, 3)) & BinaryToDecimal(Mid(CHMOD, 7, 3))
Else
CHMOD = "---"
End If
scriptColData.value = CHMOD
End Function
Function BinaryToDecimal(Binary)
Dim n, s
For s = 1 To Len(Binary)
n = n + (Mid(Binary, Len(Binary) - s + 1, 1) * (2 ^ (s - 1)))
Next
BinaryToDecimal = n
End Function
I still haven't found a solution to avoid error messages when opening DOPUS and when I navigate through folders. @Leo, any idea ?
lun. 06/01/2025 10:51:44 Colonne_CHMOD: Erreur à la ligne 23, position 2
lun. 06/01/2025 10:51:44 Colonne_CHMOD: Objet requis: 'scriptColData.tab' (0x800a01a8)
(I update my script to use regex to replace characters and use FSUtil to check ftp folder)
option explicit
Function OnInit(initData)
initData.name = "Colonne_CHMOD"
initData.desc = "Ajoute une colonne 'CHMOD' pour afficher les permissions FTP."
initData.copyright = "2025 Albator V (Michiels Thomas)"
initData.min_version = "12.0.7"
initData.version = "2.0"
InitData.group = "Colonne"
initData.default_enable = True
End Function
Function OnAddColumns(addColData)
Dim col: Set col = addColData.AddColumn
col.name = "CHMOD"
col.method = "OnCHMOD"
col.autorefresh = 2
col.justify = "center"
End Function
Function OnCHMOD(scriptColData)
Dim CHMOD, objRegExp
If NOT IsEmpty(scriptColData.tab.path) Then
If DOpus.FSUtil.PathType(scriptColData.tab.path) = "ftp" And Len(Trim(scriptColData.item.attr_text)) = 10 Then
CHMOD = Trim(scriptColData.item.attr_text)
' remplace les lettres par des 1
Set objRegExp = New RegExp
objRegExp.Global = True ' Remplacer toutes les occurrences
objRegExp.IgnoreCase = True ' Ignorer la casse (optionnel)
objRegExp.Pattern = "[a-zA-Z]" ' Expression régulière pour les lettres
CHMOD = objRegExp.Replace(CHMOD, "1")
' remplace les tirets par des 0
objRegExp.Pattern = "-"
CHMOD = objRegExp.Replace(CHMOD, "0")
' conversion en binaire
CHMOD = BinaryToDecimal(Mid(CHMOD, 2, 3)) & BinaryToDecimal(Mid(CHMOD, 5, 3)) & BinaryToDecimal(Mid(CHMOD, 7, 3))
Else
CHMOD = "---"
End If
End If
scriptColData.value = CHMOD
End Function
Function BinaryToDecimal(Binary)
Dim n, s
For s = 1 To Len(Binary)
n = n + (Mid(Binary, Len(Binary) - s + 1, 1) * (2 ^ (s - 1)))
Next
BinaryToDecimal = n
End Function