Leaderboard
Popular Content
Showing content with the highest reputation on 03/08/2020 in all areas
-
You can get rid of julianday(): WITH RECURSIVE cnt(x) AS ( SELECT '2020-03-01' d UNION ALL SELECT date(x, '+1 day') FROM cnt where x < '2020-03-31' ) SELECT x Dates FROM cnt where strftime('%w', Dates) = '1'; For your question, you can probably get away with some table-valued function, for instance by converting your string into json and using json_extract(). [see edit] Alternatively you might also built a painful CTE with clever use of string functions to achieve that, but is it worth the pain? EDIT: reality check shows that it's impossible to index a json array with a column, so place the variable of the month# - 1 (json arrays start at 0) in place of the 4 (this results in 'May'). SELECT json_extract(json_array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'), '$[4]')2 points
-
Don't believe this! You can store any type in (almost) any column of any row, you can declare fantasy types or no type at all. The only reliable way to know which default type a result column of the current row is is to invoke sqlite3_column_type(), which returns the type of the data as it is for each value of each row. Nonetheless you can still force conversion by calling a retrieval function for another type. A column declared INT can store the string value 'abc123' in a given row; sqlite3_column_type() would return SQLITE_TEXT but you can call sqlite3_column_blob() to force conversion to binary and retrieve the corresponding blob. Of course the conversions you can force this way don't always make sense. A picture stored as a 3.5 Mb blob value in a column declared CHAR and retrieved with sqlite3_column_int64() is going to be deceptive.2 points
-
[NEW VERSION] - 2 Aug 18 Added: When specifying the icon to use, if the $vIcon parameter is set to the name of an ico or exe file, the main icon within will be displayed, but if a trailing "|" followed by the icon index is added to the name, that icon from within the file is used New UDF and example in the zip below. Details of previous versions: Changelog.txt A forum query about the small pop-ups that some apps produce from the systray led me to create my version of how this can be done. By the way, I call these small GUIs "Toasts" for obvious reasons! A zip containing the UDF, an example script and my StringSize UDF (which is also required): Toast.zip As always, kind comments and constructive criticisms welcome - particularly the former! M231 point
-
I've made a library, based on AutoItObject UDF with the goal of implementing getter and setter functionality and make it possible to define new object properties in as few steps as possible. Thank you to @trancexx for getting me on the right track, and all users in Hooking into the IDispatch interface for the code to get me going. If I've forgotten to add credit, please let me know Example: #include "AutoItObject_Internal.au3" $myCar = IDispatch() $myCar.make = 'Ford' $myCar.model = 'Mustang' $myCar.year = 1969 $myCar.__defineGetter('DisplayCar', DisplayCar) Func DisplayCar($oThis) Return 'A Beautiful ' & $oThis.parent.year & ' ' & $oThis.parent.make & ' ' & $oThis.parent.model EndFunc MsgBox(0, "", $myCar.DisplayCar) More examples: https://github.com/genius257/AutoItObject-Internal/tree/master/Examples Version: 4.0.1 AutoItObject_Internal.au3 Documentation Edit2 (19th March 2017): First of all, sorry about the lack of updates on this project. I always start too many projects and end up ignoring old projects, if I run into problems ^^'. So I've started moving my AutoIt scripts to GitHub. I will still post the most recent script version here.1 point
-
SQLite returning query as JSON
dmob reacted to argumentum for a topic
#include <SQLite.au3> ;-- When SQLite is compiled with the JSON1 extensions it provides builtin tools ;-- for manipulating JSON data stored in the database. ;-- This is a gist showing SQLite return query as a JSON object. ;-- https://www.sqlite.org/json1.html Example() Func Example() _SQLite_Startup() ; "<your path>\sqlite3.dll", False, 1) ; https://www.autoitscript.com/autoit3/docs/libfunctions/_SQLite_Startup.htm _SQLite_Open() ; ...if you can not run this due to errors, get the latest DLL from https://www.sqlite.org/ If _SQLite_Exec(-1, "CREATE TABLE users (id INTEGER PRIMARY KEY NOT NULL, full_name TEXT NOT NULL, email TEXT NOT NULL, created DATE NOT NULL );") Then Return 4 If _SQLite_Exec(-1, 'INSERT INTO users VALUES ' & _ '(1, "Bob McFett", "bmcfett@hunters.com", "32-01-01"),' & _ '(2, "Angus O''Vader","angus.o@destroyers.com", "02-03-04"),' & _ '(3, "Imperator Colin", "c@c.c", "01-01-01");') Then Return 5 ; -- Get query data as a JSON object using the ; -- json_group_object() [1] and json_object() [2] functions. _SQLite_GetTable2d_ArrayToConsole("SELECT" & _ " json_group_object(" & _ " email," & _ " json_object('full_name', full_name, 'created', created)" & _ " ) AS json_result" & _ " FROM (SELECT * FROM users WHERE created > ""02-01-01"");") ; {"bmcfett@hunters.com":{"full_name":"Bob McFett","created":"32-01-01"},"angus.o@destroyers.com":{"full_name":"Angus O'Vader","created":"02-03-04"}} ; -- Get query data as a JSON object using the ; -- json_group_array() function to maintain order. _SQLite_GetTable2d_ArrayToConsole("SELECT" & _ " json_group_array(" & _ " json_object('full_name', full_name, 'created', created)" & _ " ) AS my_json_result_OrAnythingReally" & _ " FROM (SELECT * FROM users ORDER BY created);") ; [{"full_name":"Imperator Colin","created":"01-01-01"},{"full_name":"Angus O'Vader","created":"02-03-04"},{"full_name":"Bob McFett","created":"32-01-01"}] ;-- Links ;-- [1] https://www.sqlite.org/json1.html#jgroupobject ;-- [2] https://www.sqlite.org/json1.html#jobj ; example found at https://gist.github.com/akehrer/481a38477dd0518ec0086ac66e38e0e2 EndFunc ;==>Example Func _SQLite_GetTable2d_ArrayToConsole($sSQL, $hDB = -1) Local $aResult, $iRows, $iColumns If _SQLite_GetTable2d($hDB, $sSQL, $aResult, $iRows, $iColumns) Then ConsoleWrite("! SQLite Error: " & _SQLite_ErrCode($hDB) & @CRLF & "! " & _SQLite_ErrMsg($hDB) & @CRLF) Else _SQLite_Display2DResult($aResult) EndIf ConsoleWrite(@CRLF) EndFunc ;==>_SQLite_GetTable2d_ArrayToConsole Based on this example, you can build your own query. The code has all the explanations. Enjoy1 point -
AutoIt v3 and SciTE Silent Setup/Installation: change default options
Tralveller reacted to Jos for a topic
I have merged your other thread as these are related and want avoid to have to duplicate responses. Which part of the text you see is unclear as I would think it is pretty descriptive...no? So, just have a closer look and then take one question at the the time in this thread of the topic/part that is unclear.1 point -
AutoIt v3 and SciTE Silent Setup/Installation: change default options
Tralveller reacted to Jos for a topic
1. I think that /S will install x64 version when nothing is installed yet and you are on a X64 version on window. ( or are you seeing something else?) 2. It will default to "run" at first install. The easiest is to update the registry setting after installation when you want "Open": RegWrite('HKEY_CLASSES_ROOT\AutoIt3Script\Shell', '', 'REG_SZ', 'Open') Jos1 point -
_SQLite_FetchTypes()
argumentum reacted to jchd for a topic
Under the assumption that correctly declared types are actually enforced by inserts and updates, then this function will work. I only made the point to warn unsuspecting readers to fall into the trap.1 point -
speed up order by int DESC, text ASC;
argumentum reacted to jchd for a topic
The SQLite JSON1 extension provides functions to check, navigate, parse, extract, update Json data; but it does offers only very limited functionality to produce general Json output from the result of a query. It isn't completely impossible to achieve but this is very cumbersome and each query would need a long and complex ad-hoc formatting.1 point -
The "error" comes from Au3Check. Use #AutoIt3Wrapper_Run_AU3Check=n to actually run the code (which works).1 point
-
StringRegExp - replace every n-th occurence of a char
GoogleDude reacted to HurleyShanabarger for a topic
You guys are awesome - this how i did it earlier: Func _String_ReplaceOccurence(Const $_c_sStrng, Const $_c_iOccrnc, Const $_c_sChr, Const $_c_sRplc) ;|-----------------------------------------| ;| Replace occourence of substring | ;|-----------------------------------------| ;| $_c_sStrng = String to process | ;| $_c_iOccrnc = n-th occurence to replace | ;| $_c_sChr = Char to replace | ;| $_c_sRplc = Char to insert | ;|-----------------------------------------| ;|------------------------------------------------------------------------------------------------------------| ;|--------------------------------------------- Local variables ----------------------------------------------| ;|------------------------------------------------------------------------------------------------------------| Local $_l_aString = StringSplit($_c_sStrng, $_c_sChr, 3) Local $_l_iLoop, $_l_String, $_l_iOccrnc = $_c_iOccrnc < 1 ? 1 : $_c_iOccrnc ;|------------------------------------------------------------------------------------------------------------| ;|-------------------------------------------- Loop trough splits --------------------------------------------| ;|------------------------------------------------------------------------------------------------------------| For $_l_iLoop = 0 To UBound($_l_aString) - 1 $_l_String &= $_l_aString[$_l_iLoop] If $_l_iLoop < UBound($_l_aString) - 1 Then $_l_String &= (Mod($_l_iLoop + 1, $_l_iOccrnc) = 0 ? $_c_sRplc : $_c_sChr) Next Return $_l_String EndFunc ;==>_String_ReplaceOccurence1 point -
Scrollable Label
Professor_Bernd reacted to xcal for a topic
Well, there actually are Hide/ShowCaret functions. I was just destroying. I guess this is more 'proper.' #include <GUIConstants.au3> $hidden = False GUICreate('My Hide Caret', 220, 180) $edit = GUICtrlCreateEdit('Here is my edit box caret example!', 20, 20, 180, 100, $ES_READONLY) $btn1 = GUICtrlCreateButton('Show Caret', 20, 140, 80, 26) $btn2 = GUICtrlCreateButton('Hide Caret', 120, 140, 80, 26) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $btn1 DllCall('user32.dll', 'int', 'ShowCaret', 'hwnd', '') GUICtrlSetState($edit, $GUI_FOCUS) Case $btn2 GUICtrlSetState($edit, $GUI_FOCUS) DllCall('user32.dll', 'int', 'HideCaret', 'hwnd', '') EndSwitch WEnd1 point