How to open an sqlite3 database query_only?

2024-07-29 Thread phoenix27
nim import db_connector/[db_sqlite, sqlite3] type TRow = StringTableRef TRows = seq[TRow] var db:PSqlite3 proc dbOpen*(dbpath: string) {.exportpy.} = try: discard open(dbpath, db) var ret = db.create_function("powx", 2, SQ

Problem with object oriented programming

2024-07-05 Thread phoenix27
Yes, it's from my dear Delphi, from which, i'm noticing more and more, nim took a lot, including the result variable! That's good. But even if it was from 89's' pascal, what's wrong with that? Why should i always comply to some new programming FASHION "imposed" by others? And this goes beyond th

Problems debugging an app made with the wxpython library imported through nimpy

2024-06-30 Thread phoenix27
PMunch i tried wxNim months ago and i couldn't even compile the examples. I was getting an error related to an indentation problem in the library itself. I tried to solve it but i couldn't. Plus it doesn't implement the wxMediaCtrl class which i need since i'm trying to rebuild in nim an app i d

Problems debugging an app made with the wxpython library imported through nimpy

2024-06-30 Thread phoenix27
Solved!! OMG I'm really stupid!!! The problem was here: discard wx.Rescale(arr[y].width, arr[y].height, wx.IMAGE_QUALITY_HIGH) Run Of course it should be: discard img.Rescale(arr[y].width, arr[y].height, wx.IMAGE_QUALITY_HIGH) Run wx is just

Problems debugging an app made with the wxpython library imported through nimpy

2024-06-30 Thread phoenix27
Just now i tried wxnim again. I tried to compile this example: import "wxnim/wx" proc createFrame(): ptr WxFrame let f = createFrame() proc handleButtonClick(e: var WxCommandEvent) {.cdecl.} = f[].setStatusText("Quit called!") proc createFrame

Problems debugging an app made with the wxpython library imported through nimpy

2024-06-30 Thread phoenix27
Upon further investigation the problem seems to be happening before that. You are right Araq. I'll try to solve it.

Problems debugging an app made with the wxpython library imported through nimpy

2024-06-30 Thread phoenix27
Thank you for your answer Araq. I'm on windows 7 so i cannot use Valgrind. Itm.bmp is a PyObject, i create 50 of them per page using a wxTimer in order to make the scrolling of the page smooth, so i need to check in the Paint event if itm.bmp has been set so i can draw it. How can i check if itm

Problems debugging an app made with the wxpython library imported through nimpy

2024-06-30 Thread phoenix27
I'm creating an app using nimpy and wxpython. Recently i've experienced many crashes so i tried to investigate by debugging the app manually with gdb. The relevant code is here: #let address = cast[int](addr(itm.bmp)) if itm.bmp != nil:#py.None also fails discard dc.

Problem with object oriented programming

2024-06-23 Thread phoenix27
I was so taken by this object oriented stuff that i didn't consider the most obvious solution, CASTING. Anyway the last part of your answer, declaring the seq as TMedia and then adding specialized classes is really neat. I'll use this solution from now on. Thank you

Problem with object oriented programming

2024-06-23 Thread phoenix27
Often the answer comes after i already posted the problem. I was searching and came across generics, so it's really simple proc setNewDims[T](arr:seq[T])= echo arr[0].id Run It works!

Problem with object oriented programming

2024-06-23 Thread phoenix27
I have this object hierarchy with some fields : TMedia* = ref object of RootRef TVideo* = ref object of TMedia TImage* = ref object of TMedia TWebPage* = ref object of TMedia proc setNewDims(arr:seq[TMedia])= discard Run if i pass a seq[TVide

Conversion from apointer to a seq

2024-06-21 Thread phoenix27
Thank you. Then it's a bit like Pascal, which always had me confused because of that. Now i understand it better

Conversion from apointer to a seq

2024-06-20 Thread phoenix27
type TRow = seq[string] TRows = seq[TRow] proc dbGetRowsCb(arr: pointer; colCount: int32; values, columns: cstringArray): int32 {.cdecl.} = var cols:TRow for i in 0..

Recursive Fibonacci function

2023-07-04 Thread phoenix27
I used gcc 8.1.0 with the MingW distribution on windows 7. As IDE i use code::blocks. For the c version i used the -O3 flag. The strange thing is that on the web page where i took the function from () the C result is in line with the Nim one, whereas on my pc,

Recursive Fibonacci function

2023-07-04 Thread phoenix27
Thank you

Recursive Fibonacci function

2023-07-04 Thread phoenix27
import std/[times, os] proc fib(n: uint64): uint64 = if n <= 1: return n return fib(n - 1) + fib(n - 2) let time = cpuTime() echo fib(47) echo "Time taken: ", cpuTime() - time Run #include #include #include #include

Anyone tried GPT-4 for Nim?

2023-04-14 Thread phoenix27
Can someone help me? I downloaded gtk 4.4 binaries and no i didn't use msys because they removed support for windows 7. Anyway I set the environmental paths (only to the gtk bin and lib folders), then i tried to compile a little demo with nim 1.9.3 and it gave me an error: Failed to open E:prog

Nimforms - A simple GUI library for Windows

2023-04-14 Thread phoenix27
Tried, doesn't work for me. Windows 7 here. Is it possible that i cannot find a decent GUI library? What's a programming language without a decent GUI framework? I tried all or almost all of nim UI libraries and every single one has one problem or the other. When i read about winforms i was happ