Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/22/2013 in all areas

  1. John, Because you declared that function outside of the class, for every C++ file that includes the header, duplicate versions of that function will be created - which is correct compiler behavior. That's why you should either declare the function in its own C++ file, declare it as inline, or put it inside the class object definition (which behaves like inline).
    1 point
  2. dainiusb, Do NOT be like this idiot and start a third thread. M23 Edit: I see you are reading the thread to which I linked - I hope you heed the warning.
    1 point
  3. That whole RULES thing seems to elude you... "7. Do not repost the same question if the previous thread has been locked - particularly if you merely reword the question to get around one of the prohibitions listed above."
    1 point
  4. Regardless, if you want to cover all bases use a case insensitivity assertion on the regexp, like this '(?i)<H2>(.*?)</H2>' kylomas
    1 point
  5. Underdogger, Thank you. M23
    1 point
  6. Your regex pattern is wrong for that web page, this is the corrected line. $getDate = StringRegExp(FileRead("test.txt"), '<H2>(.*?)</H2>', 3) Unless you tell it to be case insensitive, the pattern has to match exactly, the H2 and /H2 are in upper case on the page downloaded.
    1 point
  7. Everything would probably work ok in the cpp file, definition and implementation. I guess the compiler doesn't like implementations in header files, not exactly that they are in the *same* file.
    1 point
  8. 1 hour might be difference from UTC to local time or daylight savings. Sorting out which is which is up to you since we have no idea of both machines' settings.
    1 point
  9. satanttin, Take a look at where this code differs from yours and see if you can work out why I have changed it: #include <GUIConstantsEx.au3> Global $sName, $sClass, $sRace, $sSex, $iGold Global $sIni = @ScriptDir & "\Test.ini" ; "U:\test.ini" ; You need to change this back $hMenu_start = GUICreate("menu_start", 153, 209, 301, 264) $cName = GUICtrlCreateButton("Name", 40, 8, 75, 25) $cRace = GUICtrlCreateButton("Race", 40, 32, 75, 25) $cClass = GUICtrlCreateButton("Class", 40, 56, 75, 25) $cSex = GUICtrlCreateButton("Sex", 40, 80, 75, 25) $cStart = GUICtrlCreateButton("Start", 40, 120, 75, 25) $cLoad = GUICtrlCreateButton("Load game", 40, 168, 75, 25) $cSave = GUICtrlCreateButton("Save Game", 40, 144, 75, 25) $iGold = 100 GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cSave IniWrite($sIni, "section", "name", $sName) IniWrite($sIni, "section", "class", $sClass) IniWrite($sIni, "section", "race", $sRace) IniWrite($sIni, "section", "sex", $sSex) IniWrite($sIni, "section", "gold", $iGold) Case $cLoad ; You need to assign the value to a variable - and supply a default return $sName = IniRead($sIni, "section", "name", "Error") $sClass = IniRead($sIni, "section", "class", "Error") $sRace = IniRead($sIni, "section", "race", "Error") $sSex = IniRead($sIni, "section", "sex", "Error") $iGold = IniRead($sIni, "section", "gold", "Error") Case $cRace $sRace = InputBox("race", "Hello " & $sName & " What is your race?") Case $cClass $sClass = InputBox("class", "Hello " & $sName & " What is your class?") Case $cSex $sSex = InputBox("sex", "Hello " & $sName & " What is your sex?") Case $cName $sName = InputBox("hello", "What's your name?") Case $cStart ; Leave this loop and start another - that way you do not get stuck in the loop that was here GUIDelete($hMenu_start) ExitLoop EndSwitch WEnd $hGame = GUICreate("test", 1026, 691, 523, 269) $cStatsg = GUICtrlCreateGroup("", 0, 0, 1025, 57) $cName = GUICtrlCreateLabel("name: " & $sName, 16, 24, 75, 17) $cRace = GUICtrlCreateLabel("Race: " & $sRace, 184, 24, 75, 17) $cClass = GUICtrlCreateLabel("Class: " & $cClass, 368, 24, 75, 17) $cSex = GUICtrlCreateLabel("Sex: " & $sSex, 520, 24, 75, 17) $cGold = GUICtrlCreateLabel("Gold: " & $iGold, 640, 24, 75, 17) ;GUICtrlCreateGroup("", -99, -99, 1, 1) ; No need to close the groups if you start another $cMenug = GUICtrlCreateGroup("", 0, 56, 209, 633) $cMenub = GUICtrlCreateButton("Menu", 64, 656, 75, 25) ;GUICtrlCreateGroup("", -99, -99, 1, 1) $cMaing = GUICtrlCreateGroup("", 208, 56, 817, 633) GUICtrlCreateGroup("", -99, -99, 1, 1) ; But you do need to close the group here GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Please ask if you have any questions - after you have searched the Help file a bit first of course. M23
    1 point
  10. Masush, Do you seriously expect anyone to answer after my post? M23
    1 point
  11. Here a litte code example: #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $hGUI = GUICreate("GDI+ Test", 300, 300) Global Const $iPic = GUICtrlCreatePic("", 100, 100, 100, 100) Global Const $hPic = GUICtrlGetHandle($iPic) GUISetBkColor(0x000000, $hGUI) GUISetState() #region GDI+ ;create an empty bitmap Global Const $iWidth = 100, $iHeight = 100 ;dimension of the bitmap Global Const $iStride = 0, $pScan0 = 0, $iPixelFormat = $GDIP_PXF32ARGB ;some bitmap parameters Global $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) Global Const $hBitmap = $aResult[6] ;this is the handle of the new empty bitmap Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;create a context to the bitmap handle to do some GDI+ operations Global Const $iBgColor = 0xFF004488 ;define background color -> ARGB _GDIPlus_GraphicsClear($hContext, $iBgColor) ;clear empty bitmap with new color Global Const $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Step_2_In.png") ;load a transparent PNG image which should be placed on the bitmap _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight) ;copy the image onto the bitmap. if image dimension <> bitmap dimension than the image will be displayed deformed ;save result as JPG and PNG (conversation is done automatically) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\New_Image.jpg") _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\New_Image.png") ;let's display the new created bitmap in the GUI Global Const $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hPic) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, 100, 100) #endregion Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) ;release image _GDIPlus_BitmapDispose($hBitmap) ;release bitmap _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Br, UEZ
    1 point
  12. 1 point
  13. Here is an example from that book that I should have included. This example demonstrates the first point of inadvertent changes. Global $the_answer = get_the_answer() Global $other_answer = get_other_answer() ; assume that get_other_answer modifies $the_answer Global $average_answer = ($the_answer + $other_answer) / 2 ; and now, $the_answer doesn't store the value you would expect This would be fine for small programs. 10,000+ programs with hundreds of functions that modify global data might be a nightmare.
    1 point
  14. No problem. But yes, keep in mind most conversions / copies in C++ are done bitwise and subject to conversion penalties (you may or may not notice for a long time ) unless you define another interface (this takes some getting used to when you're working with pointers and containers...) Anyway, the compiler should have emitted a warning when you did wstring -> string, depending on the code in the library.. If they did an explicit casting, it might not have done it. All those things that happen without you know it
    1 point
  15. It's already been stated that going from wide to narrow strings is a bad idea, however if you are certain the characters are ascii or some ANSI subset, you can use a conversion function. Check out these C++11 conversion functions, from 'The Standard C++ Library, 2nd Ed': wstring2string (and vice versa) Also more appropriately, you can convert wide strings to UTF-8, and keep that in a std::string: wstring2utf8 You can also go with widen and narrow for individual characters.
    1 point
  16. jchd

    SQL Database in autoit

    Why so? You yourself should be able to know if a table you created actually exists, don't you? Well, there are ways to do that. If you whish to ascertain that table mytable exists without massaging error returns, do this: _SQLite_QuerySingleRow($hDB, "select count(*) from sqlite_master where type = 'table' and tbl_name like 'mytable'", $row) You'll get $row[0] = 0 or 1 If you whish to create a table only if necessary, still avoiding errors, do that: _SQLite_Exec($hDB, "create table if not exists mytable ....")
    1 point
  17. jchd

    SQL Database in autoit

    As an useful complement I strongly recommend downloading the freeware version of SQlite Expert. This is the best free 3rd-party SQLite DB manager ever and since it relies on the same library as you can use with AutoIt (albeit not exactly the latest version) you know that if schema and queries work well in Expert, it will work as well in your AutoIt application. This tool will saves you really many hours of painful coding.
    1 point
  18. Most use of global variables in AutoIt are trivial. What I'm talking about are C++ objects (classes) with non-trivial constructors. I can easily demonstrate the problem in AutoIt, however, by initializing global variables using functions: ; Pre-declare the variables Global $g_nFileSize, $g_hFile ; Initialize the variables with data. $g_nFileSize = GetFileSize() $g_hFile = FileOpen("thefile.txt", 0) Func GetFileSize() ; Calculate file size using it's position. Local Const $nCurrent = FileGetPos($g_hFile) FileSetPos($g_hFile, 0, 2) Local Const $nRet = FileGetPos($g_hFile) FileSetPos($g_hFile, $nCurrent, 0) Return $nRet EndFunc In that example the variable $g_nFileSize is initialized with the output from GetFileSize(). GetFileSize() uses $g_hFile which hasn't been properly initialized yet. Reversing the initialization of the two variables will solve the problem. However, it may take quite a bit of time to figure out why $g_nFileSize is always zero if this is used in a large script. Syntax checking (Either by Au3Check or AutoIt) cannot help this situation because the variables were pre-declared so they exist. However, it's not quite as likely anyone would write code like this. It would instead be: ; Define the variables. Global $g_nFileSize = GetFileSize() Global $g_hFile = FileOpen("thefile.txt", 0) Func GetFileSize() ; Calculate file size using it's position. Local Const $nCurrent = FileGetPos($g_hFile) FileSetPos($g_hFile, 0, 2) Local Const $nRet = FileGetPos($g_hFile) FileSetPos($g_hFile, $nCurrent, 0) Return $nRet EndFunc That code produces a run-time error (but again, Au3Check cannot detect it). The problem isn't as possible in AutoIt but it's still not hard to do for any non-trivial script. In C++ it's very easy to do when objects that interact are created at the global scope.
    1 point
  19. Never mind - if it's urgent, it seems still being best just helping yourself: Global $s_ComputerName = "remotehost" Global $s_AdminUser = "Administrator" Global $s_AdminLocPW = "password" $o_SWbemLocator = ObjCreate("WbemScripting.SWbemLocator") $o_WMIService = $o_SWbemLocator.ConnectServer($s_ComputerName, "root\CIMV2", $s_AdminUser, $s_AdminLocPW) $o_ItemCollection = $o_WMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlags) Never the less: Thanks 4 reading!
    1 point
  20. Just noticed something new: I works fine on a remote computer with credentials. It only fails with credentials on the LOCAL computer! I suspect it just doesn't want to create DUPLICATE authentication to the same machine, since you're already logged in to it. Try logging on as a different user than the credentials you are using and see if that gets you access to the local stuff. muttley
    1 point
×
×
  • Create New...