Sub Main
    
    Dim str As String   
    
    str = GetDocFullPath()       ' "/home/user/document.ods"                   '
    MsgBox(GetFileBaseName(str)) ' "document.ods"                              '
    
    str = "C:\Windows\system32\drivers\etc\hosts"
    MsgBox(GetFileBaseName(str)) ' "hosts"                                     '
    
    str = "test.ods"
    MsgBox(GetFileBaseName(str)) ' "test.ods"                                  '
    
    str = "many.dots.in.file.name.ods"
    MsgBox(GetFileBaseName(str)) ' "many.dots.in.file.name.ods"                '
    
End Sub

' Returns the filename of the given path.                                      '
' For example "/home/user/document.ods" input will return "document.ods".      '
' ByVal keyword prevents FullPath from modification because by default         '
' arguments are passed by reference.                                           '
Function GetFileBaseName(ByVal FullPath As String) As String

    Dim i As Long
    Dim PathLen As Long
    Dim PathURL As String
    ' Converting to URL for Linux/Windows compatibility.                       '
    '   URL notation does not allow certain special characters to be used.     '
    '   These are either replaced by other characters or encoded. A slash      ' 
    '   (/) is used as a path separator. For example, a file referred to as    ' 
    '   C:\My File.sxw on the local host in "Windows notation" becomes         '
    '   file:///C|/My%20File.sxw in URL notation.                              '
    ' https://help.libreoffice.org/Basic/Basic_Glossary                        '
    PathURL = ConvertToURL(FullPath)
    ' FullPath could be mistakenly converted to http. For example:             '
    ' ConvertToURL("many.dots.in.file.name.ods") will be misinterpreted.       ' 
    If Left(PathURL,7) <> "file://" Then 
        PathURL = ConvertToURL("/" + FullPath)
    End If
    PathLen = Len(PathURL)
    For i = PathLen To 1 Step -1
        If Mid(PathURL,i,1) = "/" Then
            GetFileBaseName = ConvertFromURL(Right(PathURL,PathLen - i))
            Exit For
        End If
    Next i

End Function

' Returns document full path if document has a path. Returns empty string if   '
' document has no path and IgnoreNoPathError flag is set to TRUE.              '
Function GetDocFullPath(Optional IgnoreNoPathError as Boolean) As String
    
    ' Default behavior is to return empty string if document location is empty.'
    ' This can happen if document is new and not saved thus do not have a path.'
    If NOT ThisComponent.hasLocation() AND IgnoreNoPathError <> TRUE Then
        ' Err.Raise is not valid statement but will generate error anyway.     '
        Err.Raise("Document has no path. Probably because is not saved.")
    End If
    
    GetDocFullPath = ConvertFromURL(ThisComponent.getLocation())
    
End Function

Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса можно использовать чтобы получить имя файла и его расширение из полного пути к файлу.

Longstory:

Sub Main
	
	Sheet = ThisComponent.CurrentController.getActiveSheet()
	Cell = Sheet.getCellRangeByName("A1")
	Cell.setString("Hello World")
	MsgBox("Check the A1 cell contents! It will not be saved!")
	
	CloseDocIgnoreConfirmation()
	
End Sub

Function CloseDocIgnoreConfirmation()

	ThisComponent.Close(TRUE)

End Function

Short:

ThisComponent.Close(TRUE)

Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса можно использовать чтобы закрыть текущий документ, не спрашивая пользователя сохранить его или нет. Таким образом можно программно закрыть несохраненный документ, не сохранив изменения в нём и игнорируя диалоговые окна, мешающие закрытию.

Sub Main
    
    MsgBox(GetDocFullPath())
    
End Sub

' Returns document full path if document has a path. Returns empty string if   '
' document has no path and IgnoreNoPathError flag is set to TRUE.              '
Function GetDocFullPath(Optional IgnoreNoPathError as Boolean) As String
    
    ' Default behavior is to return empty string if document location is empty '
    ' This can happen if document is new and not saved thus do not have a path '
    If NOT ThisComponent.hasLocation() AND IgnoreNoPathError <> TRUE Then
        ' Err.Raise is not valid statement but will generate error anyway.     '
        Err.Raise("Document has no path. Probably because is not saved.")
    End If
    
    GetDocFullPath = ConvertFromURL(ThisComponent.getLocation())
    
End Function

Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса можно использовать чтобы получить полный путь к текущему (над которым работает макрос) документу / файлу в обычном формате.

  1. Встроенная система классов навязывает использование new при создании экземпляров объектов.
  2. Оператор return не создает блока, поэтому нельзя написать
    a = (b) ->
      return
        b + 1
    
  3. Отсутствие syntax shugar для yield. Хотя возможно что с приходом await/async yield отомрёт
  4. Comprehensions для функций (не для выражений). Вот это:
    obj = 
      prop:
        console.log "wtf!"
        if a then 1 else 2
    

    хорошо, а вот это:

    fn = (a) ->
      for b in a 
        b.increment()
    

    возвращающее массив - очень хуёво. Были проблемы из-за этого.

  5. Сука пиздец ёбаный ну это что вообще блядь сука пиздец, а
    a = ["abc","ebc","undefined","defg"]
    a = a.filter (el) -> el.indexOf "undefined" is -1
    console.dir a # ["abc","ebc","undefined","defg"]
    

    работает как

    a.filter (el) -> el.indexOf("undefined" is -1)
    

    Пиздец.

  6. coffee> a = /Письменные консультации/
    /Письменные консультации/
    coffee> a = ///Письменные консультации///
    /Письменныеконсультации/
    

    Что? Блядь, ЧТО? ЧТО БЛЯДЬ!!!!!!!!!!!!!!!
    Всё я дропаю это говно нахуй. Сударь, вы безумны. Вы безумны, сударь, блядь. Беды с башкой.
    https://github.com/jashkenas/coffeescript/issues/1199

  7. Твою мать блядь сука ёбаный ты в рот:

    for collection_id \
    in collections_list
      console.log 123
    

    17:5: error: unexpected in
    in collections_list
    ^^

[ ]
 
TypeError: object is not a function

Причина:
Написал typeof вместо instanceof

[ ]
 

The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.The folder Inbox is full, and can't hold any more messages. To make room for more messages, delete any old or unwanted mail and compact the folder.

Don't tell me to get a life.
I had one once.
It sucked.

 

In Soviet Russia, law violates you!

 

setcookie содержит в себе одну подлую опцию path. И если её не указать, куки начинают сохраняться через сраку гуся.

[ ]
 

Нужно её ЗАКОДИРОВАТЬ. И тогда она, блядь, раскодируется.

iconv = require 'iconv-lite'
fileName = '%D0%90%D0%BA%D1%82%D1%83%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9%20%D0%BF%D1%80%D0%B0%D0%B9%D1%8111.08.15.xls'
fileName = unescape(fileName)
console.log fileName
fileName = iconv.encode(fileName,'iso8859-1')
console.log fileName.toString()