Jump to content

Recommended Posts

Posted (edited)

Neither covers the case of a script run from a UNC path: \\MyServer\MyShare\MyDir\MyScript.exe

#include <File.au3>

Global $sRoot, $sDir, $sFile, $sExt
_PathSplit("X:\TestDir\TestSubDir", $sRoot, $sDir, $sFile, $sExt)
MsgBox(64, "Test", "Drive root:  " & $sRoot)

_PathSplit("\\TestSvr\TestShare\TestDir\TestSubDir", $sRoot, $sDir, $sFile, $sExt)
MsgBox(64, "Test", "UNC root:  " & $sRoot)

:mellow:

Edit: Easier with _PathSplit()

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Neither covers the case of a script run from a UNC path: \\MyServer\MyShare\MyDir\MyScript.exe

#include <File.au3>

Global $sRoot, $sDir, $sFile, $sExt
_PathSplit("X:\TestDir\TestSubDir", $sRoot, $sDir, $sFile, $sExt)
MsgBox(64, "Test", "Drive root:  " & $sRoot)

_PathSplit("\\TestSvr\TestShare\TestDir\TestSubDir", $sRoot, $sDir, $sFile, $sExt)
MsgBox(64, "Test", "UNC root:  " & $sRoot)

:mellow:

Edit: Easier with _PathSplit()

If he doesn't even know how to use StringLeft to find the drive, i think that's too profound for him .
  • Moderators
Posted (edited)

ConsoleWrite(_ScriptDrive() & @CRLF)

Func _ScriptDrive()
    Return StringRegExpReplace(@ScriptDir, "^(\w+:)(.*?\z)|^((?:\\\\|//).*?)([\\/].*?\z)", "\1\3")
EndFunc

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

ConsoleWrite(_ScriptDrive() & @CRLF)

Func _ScriptDrive()
    Return StringRegExpReplace(@ScriptDir, "^(\w+:)(.*?\z)|^((?:\\\\|//).*?)([\\/].*?\z)", "\1\3")
EndFunc
Another nice StringRegExpReplace for me to learn from, thanks SmOke_N. I have no doubt it took me longer to understand than it took you to write!
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...