Hi all, I have downloaded Nim 0.15.2 and read the text file. As per the text
file, i run the finish.exe but nothing happened. There are 22 items in my Nim
folder and it weighs 42.67 MB. I copied this folder to C drive and run the same
file again. But no way. What i did wrong. I would like to lea
Thanks @Araq and @mashingan. I have downloaded mingw and place it in C drive
and added its path into env. var like this ";C:mingwbin". I think i have done
the basic stuff and now i need to find the best IDE for Nim, am i right ?
Hi, Thanks for the replly. This is the result when i try to run it in cmd
os.nim(151) raiseOSError Unhandled Exception: The filename, dir name, or volume
label syntax is incorrect. [OSError]
I tried a new version(0.16.0) and then installation was ok. But it says that it
cannot find any proper Mingw compiler. Do i need to install a Mingw compiler ?
Hi, i cant digest the example in OOP section. This is a class example is from
VB.Net. Please somebody translate this into Nim, so that i can easily
understand what Nim offers.
1. Public Class SomeClass
2. Private m_Var1 As Integer '// An Integer member variable
3. Private m_Str1 As String
Cool.. ! Is it possible to use all type of events in all type of windows
controls ?
Hi all, Thanks a lot for com library in Nim. Its fantasctic. I like the way the
com behaves in Nim. Its just like in any scripting language. But i would like
to know that how can i wrap these com code inside a function and how can i
return a com object. Please see this code.
import
@Ward, Thanks for the reply. I think, in order to use WM_CREATE, one need to
use CreateWindowEx and other related functions.
@Ward, Do i need to git installed in my pc to install this lib ?. My cmd says
that "Error : 'git' not in PATH" What to do ?
No. "com" as return data type didn't worked
@alfrednewman, There is nothing related to this topic on that link.
No. "auto" didn't worked
@Ward, Now everything is ok. It was my mistake. I just missed the asterik (*)
sign after the proc name. Now everything looks perfect.
@Ward, Unstalled successfully. Just tested your sample code. Great !. Compiled
with "release" flag and get an exe with 352 kb. A simple window. Now, i am
planning to study your GUI library as i am interested in Windows gui
programming. My previous experience with "win api & gui" is with FreeBasi
@LeuGim, Thanks for the reply. Now everything is clear to me. Great
explanation. But one thing i forgot to add in my VB.Net class. How write a
destructor proc in Nim ?
@ward, I have a question. In win32 api, we can easily fix the location and size
of a control. But in your guiLib, i cant set the button's size and location
properly. The button is somewhat docked in the whole window. i.e., assume that
i set the button size to (120, 50) and location to (50, 50),
@enthus1ast, Thats great !. My 140 kb sized release buld gui program is only 44
kb after this "\--pass1:"-s""
@Ward, Let me try. :)
The most weird OOP syntax . Thats what is Nim OOP.
Hi all,
I am practising nim by writing a gui library based on win32 api. So far so
good. I have a working model now. But i am seeking more better method to make
this lib stronger and better.
This is my current scenario. Pseudocode;
1\. Create a type named "eventArgs".
> Members -
>
>
>
Hi all, How to write static functions inside a type ?
@Hlaaftana, Thanks. Let me try. :)
Hi all, I am practicing with win api function CreateFont. This is my code.
After setting my new font, button's text is dissappearing. How to fix it. This
is my CreateFont wrapper function.
proc createFontHadle(wHandle : HWND, fontName : string, fSize : int32,
fWeight : int32 = 400
@jlp765, Thanks. Let me try.
@jlp765, No way. It didnt worked. :(
Problem solved. It was my mistake. A typo, Its not LOGICPIXELSY, its
LOGPIXELSY.
Hi, I would like to know how to call a proc in Base class in a derived class ?
For the sake of clarity, i have included some VB.NET code. this is my
intention. See this.
Public Class Animal() '// A Base class
Public Weight_of_Animal As Integer
@mratsim, Error: attempting to call undeclared routine: 'base'
Hi, I am trying to get text from a textbox. THis is my code. I dont know how to
write the stringBuffer part.
proc getControlText*(chHwnd : HWND) : string =
var bufferSize : int32
bufferSize = SendMessage(chHwnd, WM_GETTEXTLENGTH, 0, 0)
var strBuffer : # What
I found a solution last night and i added a reply to this thread but i dont
know, it is not here for unknown reason. I think a network problem. By the way,
i tried a lot of possibilities and when tried with LPWSTR, voila ! it worked.
This is the solution.
var stringBuffer : LPWSTR
@Ward, Thanks for the reply. The code in the link looks Chinese to me. May be
because of my ignorance about "templates" and "|" sign.
@Trustable, Thanks a lot for the link. I am using winim for my hobby project.
But its very helpful to understand the code better. In this library, they are
using nim data types in win api functions. But in winim, we need to cast
everything to win api types.
Hi all, I am trying to learn templates in nim. This code is from nim tutorial.
template `!=` (a, b: untyped): untyped =
# this definition exists in the System module
not (a == b)
assert(5 != 6) # the compiler rewrites that to: assert(not (5 == 6))
R
Does the **" ``"** symbol (Acute symbol) is the one which differentiate the
template from a proc and an operator
@lscrd, Thanks for the reply. But i have one question. What is the meaning of
this line ?
new(result)
Run
Hi all, Please see this code. I somehow managed to access base class member
from child class, by giving the base as parameter in child's ctor. See this
code. But i cant access the base class member from instantiated child variable.
type
BaseWindow = ref object of RootObj
I have got a work around. See this ; I just add a variable which contain the
whole base class.
type
BaseWindow = ref object of RootObj
title : string
width : int
height : int
windowCount : int
windowList : seq[int]
@Hlaaftana, Thank you for the reply. That's a good suggestion but you didn't
tell me that does my approach contains any problem ? By the way, i didn't faced
any problem in initializing the child window.
Hi, I would like to know if there is any alternative option for "With" in
vb.net and other basic dialects. In vb.net, assume that this is our object ;
Structure Window
Public Title As String
Public Width As Integer
Public Height As Integer
End Structure
Hi, I know that seq[T] only accepts one type of data. Is there any container
data type like list in Python ? In which, we can put int, float, string,
objects etc at the same time. See this code snippet. This is what i want.
type anObject* = ref object
objList : # Here, i wa
Thanks for the reply. Well, i am not using python. But i know that python has a
container data type which contains all different types. Anyway, including
another module to my project is the last option for me. I just tested with
tuple like this. But not succeeded.
list : tuple[] #
cascade looks chinese to me.
All i new some pseudo code.
template `with`(value : someObject) =
if indentation is ok here, then allow user to write someObject's
members with a dot sign.
allow user to write as many lines starting with a dot.
Compiler, please take the value on the right of e
Hi, When i saw cascade first, i thought to study the code and build a "With"
macro after that. But most of the words in the code seems like unknown for me.
Thats why i said like that. And i used the word ugly because i am ignorant
about that. Forgive me, i didnt meant to hurt anybody nor this la
Hi, thanks for the reply. If thats the case, then i think i should need
overloaded functions for this. One string seq and 3 functions to fill the seq.
One for string, one for integer, on for decimals. Anyway, i didnt understand
the your code properly. Could you please explain a little bit. espec
Assume that i have a proc like this
proc myProc( a : auto) =
#need to check what the type of a, I am expecting an int, float, string.
# do some operations
Run
How can i check the type of a ?
Yes.
Great help ! Completely addressed the problem. I vote for the first option
which you shows through this reply. Thats really a solution for me. (But i
think you forgot to init the seq with "@[]") There is a benefit by using the
first method. When we need to loop through this seq, we can check the
I know that cascade will help me. But i had a question in my mind at that time.
I am making a GUI library with winim. So if i use cascade in my project, then
later if i send this library to one of my friends, what if they dont have
cascade in their PC ? When this thought striked me, i suddenly p
I agree but, one thing i would like to point out to you. Is there any place
where you can see a detailed tutorial about a tuple ? Especially with this
manner
1. Declare a tuple in one place. Probably on top of the file or inside a type.
2. Initialize the tuple in another place. May be inside
Thanks for the reply, but i want to check in runtime, not compile time.
Thank you :) I will check it.
proc myProc2(a : int | float | string) = discard
Run
Thats a great work around. Thanks for it. One question. This gave me error.
var mySeq : seq[ int | float | string]
Run
Any work around for this ?
This is my requirement. I am writing a combobox class. This class has an item
property. It contains a seq. One wants to insert int or string or float, or
even a window handle too. After a lot of experiments, i decided to make that
seq[string] type and if i convert the input data to string with "
I have few questions. Please answer this if you don't mind.
1. I have used ref objects in my code. Is that a good practice or bad
practice ?
2. You suggested to including base type in child type as member is a good
idea. Ok, but is there any overhead problems in it ?
For example, i only n
Ok, then, i can't use cascade since i am giving pure nim files to include his
projects.
> Three separate seqs with different data types and same name? Obviously makes
> not much sense. Ha ha.. In my sense, it was like ; "Hey compiler, this is
> 'one' seq but the data type is one among three. If the input value is int,
> then treat this seq as a seq[int]. And when the input value is
Sorry for disturbing you with my questions. Next time, when i face any
obstacles in nim coding, i will insist myself to not to ask in this forum.
I don't want to use python because these reasons.
1. I need to use a third party app to make exe from python code. (I think
python is not for windows)
2. Compiled exe is very large. A normal hello world gui app will size around
4-5 MBs.
3. Execution speed.
I will sure consider the other
Thanks. May it was my problem because, i was little frustrated when i cant find
what i was looking for. I know, i have asked too many queries in different
threads. But actually, the suggestions from others were not satisfied me, but
it was my fault, not their fault. I think its better for me to
I did not meant that you attacked me. May be you are right. I am asking
questions in the wrong way. I think i was little Impatient at that time. I
should need to try the trial and error method instead of asking in the forum.
> It's not the first time on this forum that somebody has posted a link
Sure, i will read it. >I think your own code on the top is a bit "strange and
dangerous"
I will check what i can do in that case. Thanks for pointing me the right
direction.
Thanks for the Link. Let me read. And yes, You are right. Strict typing is
problem. But i know, it will become easy after a few hobby projects. My
previous experience was in AutoIt. It has no types, Infact, we need types
actually. In VB.Net, we can use Object type and then later convert it when
Yes. Thats right. But its a dependency. My gui lib already depend upon winim.
At first my objects were like this - "control.property.text" But i have changed
that into this - "control.text"
Thanks for this. I found this today.
Hi all, I would like to know how to get the control ID, control handle and
notification code from NMHDR structure. Here is my code. Is it the right method
?
of WM_NOTIFY :
var tNMHDR : NMHDR = cast[NMHDR](repr(lParam))
Run
Finally i got the NMHDR structure without using "repr" but i cant get the
BCN_HOTITEMCHANGE code. This is my code but this if statement never resulting a
true.
of WM_NOTIFY :
tNMHDR = cast[NMHDR](lParam)
e.nCode = cast[UINT](tNMHDR.c
No replies still. Don't worry, i found the answer myself. Use "LPNMHDR" instead
of "NMHDR".
@Ward, How to use SetWindowLongPtrW in Nim ? This is my Wndproc signature
proc RED_WndProc*(hwnd: HWND, message: UINT, wParam: WPARAM, lParam:
LPARAM): LRESULT {.stdcall} =
Run
And this the call site;
OldWndProc = SetWindowLongPtrW(result, GWLP_WNDPROC,
Never mind, I found the cause of the problem. I was declared a variable as
WNDPROC and the SetWindowLongPtrW returns a LONG_PTR. That was the problem.
Solved !
Hi all, I am trying to learn templates but i coudnt get the idea of templates
easily. My aim is to mimic the cast function. Please look this --
template Cast(tp : typed, value : typed) = cast[tp](value) # Failed
template Cast[T](tp : T, value : typed) = cast[tp](value) #
Thanks for the quick answer. But i think its only work in version 0.19. I have
0.18 and its not working in my pc. But i have tested this code in Nim
Playground and it worked.
I want to install 0.19 but i am afraid that whether my current code will work
or not.
I have intalled choosenim but my CMD is not recognizing choosinm
I want to install nim 0.19 but i think either i did something wrong or
something happened wrong. After installing choosenim, i have a folder in my pc
like this--
C:\Users\Vinod\.choosenim\toolchains\nim-0.19.0
Run
But if i type "nim" in CMD, it seems that the version
Thanks for the example but i want to make a cast function for all data types,
not only for the int. Int was just an example. Thats why i planned to write a
template.
Ha ha, Those comments raising a question in my mind, especially Araq's comment.
He said
Sorry, but I don't want sugar for this sharp knife. cast is the most
dangerous feature of Nim, it's deliberately designed to be ugly.
Run
How do we do type casting without danger
In Win10 editing path is somewhat easy. But in older versions, its an annoying
task. I know that when installing some programs, they will ask to add in PATH.
So i am sure that a programmer can do this task via code. But why did some
programmers not including this feature ? I know what a PATH is.
If you ever installed python in your windows pc, the installer window has a
checkbox with a text similar to this -- "Add python to PATH"
Hi all, I am trying this piece of code
proc `=destroy`*(x : var CustomButtonClass) =
RemoveWindowSubclass(x.handle, Btn_WndProc, 1)
Run
All i want to remove the subclassing when CustomButtonClass destroyed. But the
compiler says that "signature for '=destroy'
Hi all, For the laast few weeks, i was trying to learn nim with little project.
A GUI library for windows is my project. Not fully finished yet, but i think if
i show it you guys, i can improve it more. So for your criticism, i am posting
a sample here. Please take a look .
import
GuiLib is just a file with some import and export commands. I divided my code
into modules. So there are 14 modules now. I will sure upload those files but
now i posted this code sample because i want to hear from experts that do i
need to improve anything as per this sample code. If this style
Hi @citycide, Thanks for the reply.
This library is for windows only, since it is based on Win API like wNim. If
you try to compare it to wNim, there is some slight differences. This library
tends to mimic VB.Net style. But wNim tends to mimic wxPython style.
1\. I didn't get the idea correctly
So how about this ?
type
ListBox*= ref object of Control
items* : ItemsList # all type members are starting at lower case
ItemsList = object
iList* = seq[string]
proc createListBox(me : ListBox) : HWND = # procs starting at lowerca
@Araq, Thanks. Let me check. :)
Aearq, Then it must not be a ref object. Am i right ?
Oh, I see. My CustomButtonClass is a ref object. You mean to destroy it, it
must be an object. Not ref
Hi all, I am trying to teach myself macro. This is what i want to do.
anObject.aProperty1 = anInt
anObject.aProperty2 = anStr
anObject.aProperty3 = aBool
anObject.aProperty4 = anInt2
Run
But i want to write code like this- "With" is the name of my macro.
@LeuGim, Thanks a lot. This reply is such a great help for me. But one think
you didn't included in your reply. If i loop through the "body" variable what
will i get at "i" ? I tried it so i am sure that it is not a line of code. My
first attempt was to get each line and combine it with "obj" va
@miran, Thanks for the reply. I got the idea of dumpTree because, i saw it two
days ago in another thread in this forum. But what is "quote" Could you please
explain a little bit ?
@miran, This is the result of dumpTree
StmtList
Asgn
DotExpr
Ident "abc"
Ident "x"
IntLit 56
Asgn
DotExpr
Ident "abc"
Ident "y"
IntLit 142
Run
So i think i need to rip the ident "x" and
Hi all, How about using this method to get the Ident and xxxLit from a body ?
var aStr = body.treeRepr# here i can get the complete string
representation of the code
# Now, i can search for the string "Ident" and then get the Ident.
Run
@LeuGim, Thanks for the offer but i am sorry, I don't want a full solution
because i am trying to learn this macro. Now, i think manipulating "i" directly
is the easiest option. For that, this is my assumption. Please correct me if i
am wrong.
1. In a statmentList, all lines are a valid nim s
@miran, Thanks a lot. Great help. By using nested for loops, i can get the
identifier and value individually. So this is my assumption now. Please correct
me if i am wrong.
for row in body :
result.add(nnkDotExpr(newIdentNode(obj.repr), newIdentNode(i.repr)))
Hi all, I think i find a solution.
macro With(obj : typed, body : untyped) : untyped =
result = newStmtList()
var line : string
for i in body :
line = obj.repr & "." & i.repr
result.add(parseExpr(line))
Run
@miran, I understand the importance of the word "extactly" in bold text. I am
sorry if i confused you. It was my mistake. I should have post the original
code snippet. But for easiness i just posted something else.
@LeuGim, I know that my approach was not so good. And ofcourse, i wanted to get
the "Ident" and values without parsing it as string, but i couldnt find a way.
The documentation about module macro says only about how to create code. It
doesnt says that how to rip the elements from code. Or do i m
@alehander42, Thanks for the reply. But I did not understand the "quote" All i
understood is it will give us a nimnode. If NimNode is class, then where i can
get a tutorial about all of its properties and methods. If i read such a
tutorial, i can easily understand that what i can do with a nim n
@LeuGim, I got it. I have got some sample code to study from github. First
check the kind and then rip the ident and values. Yeh... its interesting.
Thanks for enlightening me. :)
If i try to avoid the "repr", then i need to find out how many dot expressions
are in the statement. See this scenario.
anObject.aProperty4.avar = 500
anObject.aProperty3 = false
Run
I test this code with "dumpLisp" . So this type of code, i think we need to
find
1 - 100 of 218 matches
Mail list logo