Search the Community
Showing results for tags 'prefix'.
-
I haven't posted anything in the examples section for about 6-7 weeks, so felt it was that time again. This shows how to use the string functions of AutoIt and regular exp<b></b>ressions. The header pretty much explains what the function(s) do. #include <MsgBoxConstants.au3> #include <StringConstants.au3> MsgBox($MB_SYSTEMMODAL, '', _FilePrefix(@ScriptFullPath)) ; Append _ thus creating C:\Example\Test_.exe MsgBox($MB_SYSTEMMODAL, '', _FilePrefixSRE(@ScriptFullPath & '.text')) ; Append _ thus creating C:\Example\Test_.exe ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FilePrefixSRE ; Description ...: Append a prefix before the file extension. ; Syntax ........: _FilePrefixSRE($sFilePath[, $sPrefix = Default]) ; Parameters ....: $sFilePath - Filepath or name to append a prefix before the file extension. ; $sPrefix - [optional] A string value. Default is '_'. ; Return values .: Success - Filepath with the intended prefix. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _FilePrefixSRE($sFilePath, $sPrefix = Default) If $sPrefix = Default Or StringStripWS($sPrefix, $STR_STRIPALL) == '' Then $sPrefix = '_' Return StringRegExpReplace($sFilePath, '^(.+?)(\.\w+)?$', '${1}' & $sPrefix & '${2}') EndFunc ;==>_FilePrefixSRE ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FilePrefix ; Description ...: Append a prefix before the file extension. ; Syntax ........: _FilePrefix($sFilePath[, $sPrefix = Default]) ; Parameters ....: $sFilePath - Filepath or name to append a prefix before the file extension. ; $sPrefix - [optional] A string value. Default is '_'. ; Return values .: Success - Filepath with the intended prefix. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _FilePrefix($sFilePath, $sPrefix = Default) If $sPrefix = Default Or StringStripWS($sPrefix, $STR_STRIPALL) == '' Then $sPrefix = '_' Local $iDot = StringInStr($sFilePath, '.', Default, -1) - 1 If $iDot <= 0 Then $iDot = StringLen($sFilePath) Return StringLeft($sFilePath, $iDot) & $sPrefix & StringTrimLeft($sFilePath, $iDot) EndFunc ;==>_FilePrefix
- 13 replies
-
- regular expression
- string functions
-
(and 1 more)
Tagged with:
-
Prefix in variable naming - complete list?
Xibalba posted a topic in AutoIt General Help and Support
Hello, I've noticed that all the included examples uses a variable practice like so: $sWow64 (string) $hImage (handle) For $iY = 0 To $iH - 1 (integers) and so on... Which seems to be a nice practice in general. I'm wondering if there's any list of all the data types, and how they are/can/should be used when it comes to naming variables? Or quality discussions on this specific area regarding coding standards. For example, I'm not yet sure what data type $tSomething means (an example from the help file states: "a variable for use with DllStruct calls" which isn't that clear to me)- 3 replies
-
- naming
- variable naming
-
(and 2 more)
Tagged with: