GMK Posted April 12, 2012 Share Posted April 12, 2012 Here's my function:expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name ..........: _OOoCalcNumberFormat ; Description ...: Applies the specified formatting to the cells in the specified R1C1 Range. ; Syntax ........: _OOoCalcNumberFormat($oCalc, $iFormat, $vSheet, $vRangeOrRow[, $iColStart = 1[, $iRowEnd = 1[, $iColEnd = 1]]]) ; Parameters ....: $oCalc - Calc object opened by a preceding call to _OOoCalcBookOpen(), _OOoCalcBookNew(), or ; _OOoCalcBookAttach ; $iFormat - The formatting string to apply to the specified range: ; 0 ($NUMBER_STANDARD) ; 1 ($NUMBER_INT) ; 2 ($NUMBER_DEC2) ; 3 ($NUMBER_1000INT) ; 4 ($NUMBER_1000DEC2) ; 5 ($NUMBER_SYSTEM) ; 6 ($SCIENTIFIC_000E000) ; 7 ($SCIENTIFIC_000E00) ; 8 ($PERCENT_INT) ; 9 ($PERCENT_DEC2) ; 10 ($FRACTION_1) ; 11 ($FRACTION_2) ; 12 ($CURRENCY_1000INT) ; 13 ($CURRENCY_1000DEC2) ; 14 ($CURRENCY_1000INT_RED) ; 15 ($CURRENCY_1000DEC2_RED) ; 16 ($CURRENCY_1000DEC2_CCC) ; 17 ($CURRENCY_1000DEC2_DASHED) ; 18 ($DATE_SYSTEM_SHORT) ; 19 ($DATE_SYSTEM_LONG) ; 20 ($DATE_SYS_DDMMYY) ; 21 ($DATE_SYS_DDMMYYYY) ; 22 ($DATE_SYS_DMMMYY) ; 23 ($DATE_SYS_DMMMYYYY) ; 24 ($DATE_DIN_DMMMYYYY) ; 25 ($DATE_SYS_DMMMMYYYY) ; 26 ($DATE_DIN_DMMMMYYYY) ; 27 ($DATE_SYS_NNDMMMYY) ; 28 ($DATE_DEF_NNDDMMMYY) ; 29 ($DATE_SYS_NNDMMMMYYYY) ; 30 ($DATE_SYS_NNNNDMMMMYYYY) ; 31 ($DATE_DIN_MMDD) ; 32 ($DATE_DIN_YYMMDD) ; 33 ($DATE_DIN_YYYYMMDD) ; 34 ($DATE_SYS_MMYY) ; 35 ($DATE_SYS_DDMMM) ; 36 ($DATE_MMMM) ; 37 ($DATE_QQJJ) ; 38 ($DATE_WW) ; 39 ($TIME_HHMM) ; 40 ($TIME_HHMMSS) ; 41 ($TIME_HHMMAMPM) ; 42 ($TIME_HHMMSSAMPM) ; 43 ($TIME_HH_MMSS) ; 44 ($TIME_MMSS00) ; 45 ($TIME_HH_MMSS00) ; 46 ($DATETIME_SYSTEM_SHORT_HHMM) ; 47 ($DATETIME_SYS_DDMMYYYY_HHMMSS) ; 48 ($BOOLEAN) ; 49 ($TEXT) ; 50 ($INDEX_TABLE_ENTRIES) ; $vSheet - Worksheet, either by index (0-based) or name ; $vRangeOrRow - A variant value. ; $iColStart - [optional] An integer value. Default is 1. ; $iRowEnd - [optional] An integer value. Default is 1. ; $iColEnd - [optional] An integer value. Default is 1. ; Return values .: On Success - Returns 1 ; On Failure - Returns 0 and sets @error: ; |@error - 0 ($_OOoCalcStatus_Success) = No Error ; | - 3 ($_OOoCalcStatus_InvalidDataType) = Invalid Data Type ; | - 5 ($_OOoCalcStatus_InvalidValue) = Invalid Value ; |@extended - Contains Invalid Parameter Number ; Author ........: GMK ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: http://www.openoffice.org/api/docs/common/ref/com/sun/star/i18n/NumberFormatIndex.html ; http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/CellRange.html#NumberFormat ; Example .......: No ; =============================================================================================================================== Func _OOoCalcNumberFormat($oCalc, $iFormat, $vSheet, $vRangeOrRow, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1) Local $sFuncName = "_OOoCalcNumberFormat", $oSheets, $oSheetComponent, $oCellComponent If Not IsObj($oCalc) Then __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidDataType") Return SetError($_OOoCalcStatus_InvalidDataType, 1, 0) EndIf If Not IsInt($iFormat) Then __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidDataType") Return SetError($_OOoCalcStatus_InvalidDataType, 2, 0) EndIf If $iFormat < 0 Or $iFormat > 50 Then __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidValue") Return SetError($_OOoCalcStatus_InvalidValue, 2, 0) EndIf If Not IsInt($vSheet) And Not IsString($vSheet) Then __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidDataType") Return SetError($_OOoCalcStatus_InvalidDataType, 3, 0) EndIf If Not IsInt($vRangeOrRow) And Not StringRegExp($vRangeOrRow, "[A-Z,a-z]") Then __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidValue") Return SetError($_OOoCalcStatus_InvalidValue, 4, 0) EndIf If Not IsInt($iColStart) Then __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidDataType") Return SetError($_OOoCalcStatus_InvalidDataType, 5, 0) EndIf $oSheets = $oCalc.getSheets() If IsString($vSheet) Then $oSheetComponent = $oSheets.getByName($vSheet) Else If $vSheet < 0 Then $vSheet = 0 $oSheetComponent = $oSheets.getByIndex($vSheet) EndIf If Not StringRegExp($vRangeOrRow, "[A-Z,a-z]", 0) Then If $vRangeOrRow < 1 Then $vRangeOrRow = 1 $oCellComponent = $oSheetComponent.getCellRangeByPosition($iColStart - 1, $vRangeOrRow - 1, $iColStart - 1 + $iColEnd - 1, $vRangeOrRow - 1 + $iRowEnd - 1) Else $oCellComponent = $oSheetComponent.getCellRangeByName($vRangeOrRow) EndIf $oCellComponent.NumberFormat = $iFormat Return SetError($_OOoCalcStatus_Success, 0, 1) EndFunc ;==>_OOoCalcNumberFormat When I use:#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 It says "WARNING: $oCellComponent: declared, but not used in func." How can I get around that when the NumberFormat property is set with the equal sign (if I want to use those wrapper parameters for the sake of UDF standards)? Link to comment Share on other sites More sharing options...
Chimaera Posted April 12, 2012 Share Posted April 12, 2012 (edited) Use #forceref Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Edited April 12, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
guinness Posted April 12, 2012 Share Posted April 12, 2012 (edited) As Chimaera said in certain circumstances #forceref has to be used when variables must be passed to a function, a good example is intercepting a Windows Message. Try the following. Local $sFuncName = "_OOoCalcNumberFormat", $oSheets, $oSheetComponent, $oCellComponent #forceref $oCellComponent Edited April 12, 2012 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
acidman Posted April 12, 2012 Share Posted April 12, 2012 First of you should do research on how to declare variables and in which scope, every Variable scope has different uses. It's best to declare all your variables on top of the script in the global scope becuase then any variable in the global scope can be used by any function, if you declare a variable in the local scope it's destroyed when the function ends. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Scopes", 150, 271, 192, 114) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") Global $Label1 = GUICtrlCreateLabel("ID number:", 8, 8, 56, 17) Global $Input1 = GUICtrlCreateInput("", 8, 32, 121, 21) $Label2 = GUICtrlCreateLabel("Name", 8, 64, 32, 17) $Input2 = GUICtrlCreateInput("", 8, 88, 121, 21) Global $Button1 = GUICtrlCreateButton("Show Info", 8, 176, 123, 25) GUICtrlSetOnEvent(-1, "Button1Click") Global $Label3 = GUICtrlCreateLabel("Age:", 8, 120, 26, 17) $Input3 = GUICtrlCreateInput("", 8, 144, 121, 21) Global $Button2 = GUICtrlCreateButton("Show Age", 8, 208, 123, 25) GUICtrlSetOnEvent(-1, "Button2Click") Global $Label4 = GUICtrlCreateLabel("Coded by ac1dm4nner", 8, 240, 111, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $readGlobal While 1 Sleep(100) WEnd Func Button1Click() Local $Read = GUICtrlRead($Input1) Local $Read1 = GUICtrlRead($Input2) Local $Read2 = GUICtrlRead($Input3) MsgBox(64, " Variables in the Local Scope's Data will be destroyed when The function ends", $read & @CRLF & $Read1 & @CRLF & $Read2) EndFunc Func Button2Click() $ReadGlobal = Guictrlread($Input3) Msgbox(64, "Global Scope", $readglobal & @crlf & "A variable in the global scope" & "You can use A variable declared in the Global Scope" & "will get the new Value becuase a Var In the Global scope can be used infinite times" & @Crlf & "From any function, Now Change the value in input3" & @crlf & "You'll see the data has changed too") EndFunc Func Form1Close() Exit EndFunc Do proper research on how to declare variables, it's always important to have declarations in your script it makes you Program A lot easier to code... Good Luck Man!! I hope this has helped you a bit... [u]My dream is to have a dream...[/u] Link to comment Share on other sites More sharing options...
guinness Posted April 12, 2012 Share Posted April 12, 2012 It's best to declare all your variables on top of the script in the global scope becuase then any variable in the global scope can be used by any function.Who told you it's best? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
acidman Posted April 12, 2012 Share Posted April 12, 2012 I think it's best Guinness, I declare all my variables in the Global scope it makes everything much, much easier to code and often best to declare in local and Global scope, if I am not mistaken on a thread you and some other folks told me it's best to declare Variables in the local and Global Scope... [u]My dream is to have a dream...[/u] Link to comment Share on other sites More sharing options...
guinness Posted April 12, 2012 Share Posted April 12, 2012 I think it's best Guinness, I declare all my variables in the Global scope it makes everything much, much easier to code and often best to declare in local and Global scope, if I am not mistaken on a thread you and some other folks told me it's best to declare Variables in the local and Global Scope... I think you misinterpreted my point as I was responding to your question of 'Declaring variables and why?' not 'Should I declare all my variables in Global.' I merely provided information on how to correctly declare Global and Local variables. This is why I said it's best practice to declare Global variables at the top of your script, not declare all variables in Global at the top of your script, slightly different.Declaring all variables might be easy for you but for most it becomes a logistical nightmare, not knowing what is what. How I break it down is fewer Global variables equals better code and a lot easier to read. Perhaps have a read of what about the question of Global variable use. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
GMK Posted April 13, 2012 Author Share Posted April 13, 2012 OK...back on topic. Thanks Chimaera and guinness--that's just what I needed! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now