I need "windowsx.d" Someone can send It to me?

2020-09-25 Thread Marcone via Digitalmars-d-learn
I need windowsx.d but for I don't know the reason is not in dmd. 
Someone that have it can send to me? I don't know convert 
windowsx.h to windowsx.d


Re: I need "windowsx.d" Someone can send It to me?

2020-09-25 Thread Marcone via Digitalmars-d-learn
On Friday, 25 September 2020 at 17:00:04 UTC, Denis Feklushkin 
wrote:

On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote:
I need windowsx.d but for I don't know the reason is not in 
dmd. Someone that have it can send to me? I don't know convert 
windowsx.h to windowsx.d


Try to convert C header into D file by dpp tool.


When I try dpp in this tutorial:

 Windows

Install http://releases.llvm.org/6.0.1/LLVM-6.0.1-win64.exe 
into C:\Program Files\LLVM\, making sure to tick the "Add LLVM to 
the system PATH for all users" option.

Make sure you have LDC installed somewhere.
Compile with dub build --compiler=C:\path\to\bin\ldc2.exe.
Copy C:\Program Files\LLVM\bin\libclang.dll next to the 
d++.exe in the bin directory.


When I try this command:
Compile with dub build --compiler=C:\path\to\bin\ldc2.exe

I get this error:

Neither a package description file, nor source/app.d was found in
D:\Downloads
Please run DUB from the root directory of an existing package, or 
run

"dub init --help" to get information on creating a new package.

No valid root package found - aborting.



Re: Getting Qte5 to work

2020-10-28 Thread Marcone via Digitalmars-d-learn

Look this video https://www.youtube.com/watch?v=Es9Qs9_1ipk


How Stop Worker Thread if Owner Thread is Finished?

2020-10-26 Thread Marcone via Digitalmars-d-learn
Because when the main thread is completed the worker thread 
continues to run.


Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Marcone via Digitalmars-d-learn
I want to use isDaemon to automatic stop worker thread if ownner 
thread is finished


Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Marcone via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 12:16:01 UTC, Rene Zwanenburg 
wrote:

On Tuesday, 27 October 2020 at 11:36:42 UTC, Marcone wrote:
I want to use isDaemon to automatic stop worker thread if 
ownner thread is finished


Terminating threads without properly unwinding the stack is 
generally a very bad idea. Most importantly the destructors of 
stucts on the stack won't run which can cause problems like 
locks not being released.


This isn't specific to D either. For example Raymond Chen 
writes about the TerminateThread function in Windows here:

https://devblogs.microsoft.com/oldnewthing/20150814-00/?p=91811

You should signal the thread somehow that it's time to stop 
working


isDaemon: A daemon thread is automatically terminated when all 
non-daemon threads have terminated.


How kill executables started with spawnShell or executeShell when program finish?

2020-10-27 Thread Marcone via Digitalmars-d-learn
Becouse my program use plink.exe running with spawnShell or 
executeShell.
But when my program finish with some crash, or killed with 
windows task manager by user, Plink still running. How can I stop 
all process initialized with spawnShell or executeShell when 
program finish? I another works, how can I make plink.exe only 
lives when program is running?


How Install and Configure DCD (D Completion Daemon) on Sublime Text?

2020-07-20 Thread Marcone via Digitalmars-d-learn
How Install and Configure DCD (D Completion Daemon) on Sublime 
Text?

I need auto complete for the Dlang in Sublime Text.


Re: How spand array for use with functions arguments like tuple?

2020-07-20 Thread Marcone via Digitalmars-d-learn

On Sunday, 19 July 2020 at 23:05:45 UTC, Marcone wrote:

How spand array for use with functions arguments like tuple?


expand*


How can I make DMD stop on the first fatal error? (-Wfatal-errors)

2020-07-07 Thread Marcone via Digitalmars-d-learn
How can I make DMD stop on the first fatal error like 
-Wfatal-errors on C++?


Re: How can I make executeShell ask for Admin Elevation?

2020-07-13 Thread Marcone via Digitalmars-d-learn

On Monday, 13 July 2020 at 12:28:24 UTC, aberba wrote:

On Monday, 13 July 2020 at 00:57:02 UTC, Marcone wrote:

On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote:
I don't want start program with admin elevation, but ask user 
for admin permission when some function is called.


alias runas = compose!(x => to!bool((cast(int) x) > 32), x => 
ShellExecute(null, "runas", "cmd", cast(wchar*) "/c \"cd /d %s 
&& %s\"".format(getcwd(), x).to!wstring, null, 
SW_HIDE).WaitForSingleObject(WAIT_TIMEOUT));


runas("netsh winhttp set proxy 127.0.0.1:9666")


Can you put it into a small dub package?


I do not know how to do that. Observation: Remove the code 
.WaitForSingleObject (WAIT_TIMEOUT)


Error: `std.uni.isUpper` conflicts with `std.ascii.isUpper`

2020-07-14 Thread Marcone via Digitalmars-d-learn

import std: isUpper, writeln;

void main(){
writeln(isUpper('A'));
}

Why I get this error? How can I use isUpper()?


How can I make executeShell ask for Admin Elevation?

2020-07-11 Thread Marcone via Digitalmars-d-learn
I don't want start program with admin elevation, but ask user for 
admin permission when some function is called.


Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn

On Sunday, 12 July 2020 at 12:31:17 UTC, Kagamin wrote:
You call ShellExecute with "runas" verb: 
https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea


Please give me a litle simple example ruining this command: 
"netsh winhttp set proxy 127.0.0.1:"


Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn

On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote:
I don't want start program with admin elevation, but ask user 
for admin permission when some function is called.


How can I get return code ans stdout of this code:

ShellExecute(null, "runas", "cmd", "/c netsh winhttp set proxy 
127.0.0.1:1234" , null, SW_HIDE);


Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn

On Sunday, 12 July 2020 at 12:31:17 UTC, Kagamin wrote:
You call ShellExecute with "runas" verb: 
https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea


I need return code and stdout.


Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn

On Sunday, 12 July 2020 at 17:28:01 UTC, Kagamin wrote:

I mean runas your own program.


I need a function that ask for admin at runtime only for one 
function


Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn

On Sunday, 12 July 2020 at 17:19:08 UTC, Kagamin wrote:
Well, you can elevate your own program and tell it to run that 
command, collect the result and send it back through e.g. 
shared memory.


I don't want start with elevation, becouse program must be 
avaliable even user is not admin. Only ask for admin if normal 
usar ask for a command that need elevation.


Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn

On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote:
I don't want start program with admin elevation, but ask user 
for admin permission when some function is called.


alias runas = compose!(x => to!bool((cast(int) x) > 32), x => 
ShellExecute(null, "runas", "cmd", cast(wchar*) "/c \"cd /d %s && 
%s\"".format(getcwd(), x).to!wstring, null, 
SW_HIDE).WaitForSingleObject(WAIT_TIMEOUT));


runas("netsh winhttp set proxy 127.0.0.1:9666")


Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn

On Sunday, 12 July 2020 at 21:50:06 UTC, Ali Çehreli wrote:

On 7/11/20 7:10 PM, Marcone wrote:

[...]


Here is a hacky solution that attempts the command and fails 
back to asking the password. It should work on POSIX systems. 
(Tested on Linux.)


[...]


I need for Windows, it not work on windows.


How import DUB packcages directly and compile with DMD without use dub.exe?

2020-07-16 Thread Marcone via Digitalmars-d-learn

I just want import in file and run with dmd.


How can I get Phobos Runtime Library docummentation in PDF?

2020-07-17 Thread Marcone via Digitalmars-d-learn
I need full Phobos Runtime Library docummentation in only one PDF 
file.


How spand array for use with functions arguments like tuple?

2020-07-19 Thread Marcone via Digitalmars-d-learn

How spand array for use with functions arguments like tuple?


Re: How import DUB packcages directly and compile with DMD without use dub.exe?

2020-07-16 Thread Marcone via Digitalmars-d-learn

On Thursday, 16 July 2020 at 11:52:39 UTC, Andre Pany wrote:

On Thursday, 16 July 2020 at 11:06:01 UTC, Marcone wrote:

I just want import in file and run with dmd.


Execute dub build with verbose output. You will find the info 
how dub is calling dmd.


Kind regards
Andre


dub is calling dmd with 
-IC:\Users\Usuario\AppData\Local\dub\packages\scriptlike-0.10.3\scriptlike\src but I want dmd auto import any in dub packages, for example: -IC:\Users\Usuario\AppData\Local\dub\packages\.


I need an Easy example to understand Alias This

2020-07-06 Thread Marcone via Digitalmars-d-learn
Hi, I study Dlang for one year, and I can't understand alias 
this. I need an Easy example to understand Alias This.


Re: I need an Easy example to understand Alias This

2020-07-06 Thread Marcone via Digitalmars-d-learn

On Tuesday, 7 July 2020 at 00:42:40 UTC, Ali Çehreli wrote:

On 7/6/20 5:35 PM, Marcone wrote:
Hi, I study Dlang for one year, and I can't understand alias 
this. I need an Easy example to understand Alias This.


Is the following example useful?

  http://ddili.org/ders/d.en/alias_this.html

Ali


I can't undestand it. I need a simple example.


How can I use file from resource .res without copy it to hard disc?

2021-01-11 Thread Marcone via Digitalmars-d-learn
I want use file direct from resource .res without copy it to hard 
disc. How can I make it?


Parameter with indetermined tuple elements type?

2021-01-11 Thread Marcone via Digitalmars-d-learn
I want to create a function that receive a tuple (need be a 
tuple) with indetermined length and indetermined elements type 
without template. The argument need be a tuple, but length and 
elements types indetermineds. How can I make it?


Re: How can I directly reffer literal element itself inside [] slice?

2021-01-11 Thread Marcone via Digitalmars-d-learn

I am using it:


// Tipo Nulo.
class None {}

// Função slice()
auto slice(T1, T2, T3 = None)(T1 conteudo, T2 inicio, T3 fim = 
T3.init) {

int start, end, startlen;
	static if (is(T2 == int)) {inicio = inicio < 0 ? conteudo.length 
+ inicio : inicio;}
	static if (is(T3 == int)) {fim = fim <= 0 ? conteudo.length + 
fim : fim;}
	static if (is(T2 == int)) {start = inicio;} else static if 
(is(T2 == string)){start = conteudo.countUntil(inicio);}
	static if (is(T2 == string)) {static if (is(T1 == 
string)){startlen = start + inicio.length + 1;} else {startlen = 
start + 1;}}
	static if (is(T3 == int)) {end = fim;} else static if (is(T3 == 
string)){end = startlen + conteudo[startlen..$].countUntil(fim);}
	static if (is(T3 == None)) {return conteudo[start];} else 
{return conteudo[start..end];}

}


How can I directly reffer literal element itself inside [] slice?

2021-01-11 Thread Marcone via Digitalmars-d-learn



I can reffer length of literal string using $.

"Hello World"[0..$]

But I want make like it witout use variable name.

"Hello World"[0..?.indexOf("o")]


Re: How can I directly reffer literal element itself inside [] slice?

2021-01-11 Thread Marcone via Digitalmars-d-learn

On Monday, 11 January 2021 at 16:41:03 UTC, oddp wrote:

On 11.01.21 16:45, Marcone via Digitalmars-d-learn wrote:

"Hello World"[0..?.indexOf("o")]


Does until [1] do the trick?

"Hello World".until("o") // => "Hell"

[1] https://dlang.org/library/std/algorithm/searching/until.html


I want more support inside slice []


Re: How can I directly reffer literal element itself inside [] slice?

2021-01-11 Thread Marcone via Digitalmars-d-learn

On Monday, 11 January 2021 at 21:01:57 UTC, Paul Backus wrote:

On Monday, 11 January 2021 at 15:45:51 UTC, Marcone wrote:


I can reffer length of literal string using $.

"Hello World"[0..$]

But I want make like it witout use variable name.

"Hello World"[0..?.indexOf("o")]


The exact syntax you want is impossible. The closest you can 
get is to use an `enum` constant, which is essentially a named 
literal:


enum hello = "Hello World";
writeln(hello[0 .. hello.countUntil("o")]); // "Hell"


I don't want use enum, I want use literal.


How build DCD on Windows?

2021-01-11 Thread Marcone via Digitalmars-d-learn
Hi, Someone can Help me build exe dcd server and client on 
WIndows? Step by step? Becouse the informations disponible is 
very hard to undestand.


Can alias compose! receive more than one argument?

2021-01-07 Thread Marcone via Digitalmars-d-learn

I get this eror:


Example:

alias a = compose!(x,y => x*y);

writeln(a(2,5));

// Error: onlineapp.d(4): Error: undefined identifier x


Re: Can alias compose! receive more than one argument?

2021-01-07 Thread Marcone via Digitalmars-d-learn

My mistake:

alias a = compose!((x,y) => x*y);


Re: My first application in Dlang

2020-12-02 Thread Marcone via Digitalmars-d-learn

On Thursday, 3 December 2020 at 02:44:40 UTC, Ali Çehreli wrote:

On 12/2/20 5:46 PM, Marcone wrote:
Hello, my name is Marcone, I live in Brazil, and I have been 
studying Dlang for a year. I finished my first application in 
Dlang with a graphical interface in Win32api and made it 
available on the internet for anyone who wants to download it. 
Here is the program link. As a beginner in the D programming 
language, I would like a note from you who have been D 
programmers for a long time if I am doing well. What did you 
think about the application?


Link of my First Aplication created with Dlang and Win32api : 
https://sourceforge.net/projects/direct-http-tunnel/


Thank you.


Cool. :)

But did you want to share your *source* code? All I see there 
is a .exe, which I would not start due to risk of viruses (of 
course unknown to you).


Ali


Hi, are you Ali Çehreli author of Programming in D book? I 
learned Dlang by reading this book on my Kindle. If I published 
my source code you wouldn't understand. I created a module with 
functions so useful, that using UFCS if it weren't for the keys 
delimiting the blocks, anyone would think they're reading a 
Python code.


My first application in Dlang

2020-12-02 Thread Marcone via Digitalmars-d-learn
Hello, my name is Marcone, I live in Brazil, and I have been 
studying Dlang for a year. I finished my first application in 
Dlang with a graphical interface in Win32api and made it 
available on the internet for anyone who wants to download it. 
Here is the program link. As a beginner in the D programming 
language, I would like a note from you who have been D 
programmers for a long time if I am doing well. What did you 
think about the application?


Link of my First Aplication created with Dlang and Win32api : 
https://sourceforge.net/projects/direct-http-tunnel/


Thank you.


Re: How can I convert Hexadecimal to RGB Color and vice-versa?

2020-11-23 Thread Marcone via Digitalmars-d-learn

// Função hex2rgb()
uint hex2rgb(string hexcolor) nothrow {
try {
uint value;
hexcolor.stripLeft("#").formattedRead!"%x"(value);
return value;
} catch(Throwable){return 0;}
}


// Função rgb2hex()
string rgb2hex(uint rgbcolor) nothrow {
try {
return "#%s".format(toHex(cast(const(BigInt)) rgbcolor));
} catch(Throwable){return "";}
}


Re: How make Optional pre determined parameter type without overload function?

2020-11-28 Thread Marcone via Digitalmars-d-learn

On Sunday, 29 November 2020 at 02:55:02 UTC, Ali Çehreli wrote:

On 11/28/20 6:40 PM, Marcone wrote:

void a(T1, T2)(T1 b, T2 c){
 // I need parameter "c" optional, but only (String or 
int). How can I make it without overload function?

}


Since it's optional, T2 must have a default type. I made it 
'int' below.


void a(T1, T2 = int)(T1 b, T2 c = T2.init)
if (is (T2 == string) ||
is (T2 == int))
{
  // ...
}

void main() {
  a(1.5);
  a(2.5, "hello");
  a(3.5, 42);
  static assert(!__traits(compiles, a(4.5, 5.5)));
}


Thank you! work fine!


How make Optional pre determined parameter type without overload function?

2020-11-28 Thread Marcone via Digitalmars-d-learn

void a(T1, T2)(T1 b, T2 c){
	// I need parameter "c" optional, but only (String or int). How 
can I make it without overload function?

}


Re: How make Optional pre determined parameter type without overload function?

2020-12-02 Thread Marcone via Digitalmars-d-learn

Now my slice works fine.


// Tipo Nulo.
class None {}

// Função slice()
auto slice(T1, T2, T3 = None)(T1 conteudo, T2 inicio, T3 fim = 
T3.init) {

int start, end, startlen;
	static if (is(T2 == int)) {inicio = inicio < 0 ? conteudo.length 
+ inicio : inicio;}
	static if (is(T3 == int)) {fim = fim <= 0 ? conteudo.length + 
fim : fim;}
	static if (is(T2 == int)) {start = inicio;} else static if 
(is(T2 == string)){start = conteudo.countUntil(inicio);}
	static if (is(T2 == string)) {static if (is(T1 == 
string)){startlen = start + inicio.length + 1;} else {startlen = 
start + 1;}}
	static if (is(T3 == int)) {end = fim;} else static if (is(T3 == 
string)){end = startlen + conteudo[startlen..$].countUntil(fim);}
	static if (is(T3 == None)) {return conteudo[start];} else 
{return conteudo[start..end];}

}



CMD && comand not work

2020-12-10 Thread Marcone via Digitalmars-d-learn
In this very generic example && not work to finalize the instruct 
and start a new instruct. Yes, I know dmd can build and run 
without it, but this is only a example.


execute(["cmd", "/c", "dmd test.d", "&&", "start test.exe"]);

How can I substitute && ?


Re: UFCS functions with both pointers and refs

2020-12-18 Thread Marcone via Digitalmars-d-learn
Two differents types; Foo type and pointer type. Need function 
overload foe each or just use ref and avoid pointer.





How can I wrap SSL on Dlang Socket?

2020-11-15 Thread Marcone via Digitalmars-d-learn

How can I wrap SSL on Dlang Socket like I wrap in Python?


How can execute method in new Thread?

2020-11-14 Thread Marcone via Digitalmars-d-learn

My simple example code:

import std;

struct Fruit {
string name;
this(string name){
this.name = name;
}

void printmyname(){
writeln(this.name);
}

void showname(){
		task!this.printmyname().executeInNewThread(); // Error here!! 
Can not send this.printmyname() tonew thread.

}
}


void main(){
Fruit f = Fruit("Banana");
f.showname();
}


Error: 
D:\dmd2\windows\bin\..\..\src\phobos\std\parallelism.d(516): 
Error: struct `Fruit` does not overload ()


Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn

On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote:

On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote:

On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:

On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:

auto mytime = Clock.currTime().toUnixTime()

writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make 
some like this in D?


auto mytime = Clock.currTime;
writefln("%02dh:%02dm:%02ds", mytime.hour, mytime.minute, 
mytime.second);


auto mytimeFromUnix = SysTime.fromUnixTime(1234567890);
writefln("%02dh:%02dm:%02ds", mytimeFromUnix.hour, 
mytimeFromUnix.minute, mytimeFromUnix.second);


https://run.dlang.io/is/TAO6Q9


Your code get wrong hour result: 21hours, only minuts and 
seconds correct.


If you're looking at the run.dlang.io output, the server is 
probably in a different timezone than yours.


Tested locally at 04:14 instead of sleeping:

$ dmd -run mytime.d
04h:14m:06s
00h:31m:30s


I do this:

// Função strftime()
string strftime(string text, int tempo){
int H = to!int(dur!"seconds"(tempo).total!"hours");
int M = to!int(dur!"seconds"(tempo % (60*60)).total!"minutes");
	int S = to!int(dur!"seconds"(tempo % (60*60) % 
60).total!"seconds");
	return text.replace("%H", H.to!string).replace("%M", 
M.to!string).replace("%S", S.to!string);

}


Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn

On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote:

On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote:

On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:

On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:

auto mytime = Clock.currTime().toUnixTime()

writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make 
some like this in D?


auto mytime = Clock.currTime;
writefln("%02dh:%02dm:%02ds", mytime.hour, mytime.minute, 
mytime.second);


auto mytimeFromUnix = SysTime.fromUnixTime(1234567890);
writefln("%02dh:%02dm:%02ds", mytimeFromUnix.hour, 
mytimeFromUnix.minute, mytimeFromUnix.second);


https://run.dlang.io/is/TAO6Q9


Your code get wrong hour result: 21hours, only minuts and 
seconds correct.


If you're looking at the run.dlang.io output, the server is 
probably in a different timezone than yours.


Tested locally at 04:14 instead of sleeping:

$ dmd -run mytime.d
04h:14m:06s
00h:31m:30s


See my program for you understand better:
Here is the picture of my program, see red mark: 
https://i.imgur.com/D5nsNHM.png


How can I set Timeout of Socket?

2020-11-14 Thread Marcone via Digitalmars-d-learn

Socket s = new Socket(AddressFamily.INET, SocketType.STREAM);
s.connect(new InternetAddress("domain.com", 80));

I want that program raise an error if reach for example 30 
seconds of timeout.






Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn

On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:

On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:

auto mytime = Clock.currTime().toUnixTime()

writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some 
like this in D?


auto mytime = Clock.currTime;
writefln("%02dh:%02dm:%02ds", mytime.hour, mytime.minute, 
mytime.second);


auto mytimeFromUnix = SysTime.fromUnixTime(1234567890);
writefln("%02dh:%02dm:%02ds", mytimeFromUnix.hour, 
mytimeFromUnix.minute, mytimeFromUnix.second);


https://run.dlang.io/is/TAO6Q9


Your code get wrong hour result: 21hours, only minuts and seconds 
correct.

I'm using this example:

import std;
import core.thread;

// Functiono strftime()
string strftime(string text, int tempo){
int H = to!int(tempo / (60*60));
int M = to!int(tempo % (60*60) / 60);
int S = to!int(tempo % (60*60) % 60);
	return text.replace("%H", H.to!string).replace("%M", 
M.to!string).replace("%S", S.to!string);

}

void main(){
int starttime = Clock.currTime().toUnixTime();
Thread.sleep(5.seconds);
int endtime = Clock.currTime().toUnixTime() - starttime;
writeln(strftime("%Hh:%Mm:%Ss", endtime));
}


How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn

auto mytime = Clock.currTime().toUnixTime()

writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some 
like this in D?


Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn

On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:

On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:

auto mytime = Clock.currTime().toUnixTime()

writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some 
like this in D?


auto mytime = Clock.currTime;
writefln("%02dh:%02dm:%02ds", mytime.hour, mytime.minute, 
mytime.second);


auto mytimeFromUnix = SysTime.fromUnixTime(1234567890);
writefln("%02dh:%02dm:%02ds", mytimeFromUnix.hour, 
mytimeFromUnix.minute, mytimeFromUnix.second);


https://run.dlang.io/is/TAO6Q9


I want to convert seconds to hour, minut and second.


Why can not use tray/catch inside finally block?

2020-11-16 Thread Marcone via Digitalmars-d-learn
Some operations in finally block may throw and can not be used 
inside nothrow functon. Why can not use tray/catch inside finally 
block?


Re: Function Pointer Not Working

2020-11-19 Thread Marcone via Digitalmars-d-learn

I will wait with this code.
WaitForSingleObject(threading, INFINITE);


How Performance down slow it is using UFCS friendly function?

2020-11-20 Thread Marcone via Digitalmars-d-learn

// Função receive()
char[] receive(Socket socket, int size = 8192) nothrow {
try {
char[] buffer;
buffer.length = size;
int rq = socket.receive(buffer);
return buffer[0..rq];
} catch(Throwable){return null;}
}


s = new Socket(AddressFamily.INET, SocketType.STREAM);
writeln(s.receive(8192)); // How slow is using as friendly 
function?


Function Pointer Not Working

2020-11-18 Thread Marcone via Digitalmars-d-learn

// Function threadingw()
void threadingw(HWND hwn, void delegate() fun) nothrow {
try {
// Function _fun()
extern(Windows)
uint _fun(void * arg){
			(*(cast(void delegate()*) arg))(); // Do not show "Hello 
World!" :(

return 0;
}
CreateThread(null, 0, &_fun, , 0, null);
} catch(Throwable){}
}

void main(){
null.threadingw({writeln("Hello World!");});

}


Re: Function Pointer Not Working

2020-11-19 Thread Marcone via Digitalmars-d-learn

Solved replacing this line:

CreateThread(null, 0, &_fun, , 0, null);

to this code:
task!({CreateThread(null, 0, &_fun, , 0, 
null);}).executeInNewThread();


Re: Function Pointer Not Working

2020-11-19 Thread Marcone via Digitalmars-d-learn

On Thursday, 19 November 2020 at 15:51:09 UTC, Kagamin wrote:
The delegate is stored on the stack of the calling thread, the 
created thread loads it from there, but the calling thread 
doesn't wait for that and clobbers the stack right away. If you 
were lucky your code would crash.


The thread that I do wait ultil function is finished. Using a 
while with 3 seconds to verify if thread id is in running list, 
and break if not finishing owner thread.


I need a most simple and easy example to understand UDA.

2020-11-01 Thread Marcone via Digitalmars-d-learn

I need a most simple and easy example to understand UDA.


How add class or struct member after construction?

2020-11-05 Thread Marcone via Digitalmars-d-learn
How add class or struct member after construction? Is it possible 
in D? How?


Re: DConf talk : Exceptions will disappear in the future?

2021-01-05 Thread Marcone via Digitalmars-d-learn

Bye bye nothrow functions in Dlang.


How define accepted types in a template parameter?

2021-01-16 Thread Marcone via Digitalmars-d-learn
For example, I want my function template to only accept integer 
or string;


How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-18 Thread Marcone via Digitalmars-d-learn
How can I create a Standalone Bundle Portable file application 
using Dlang?


Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-20 Thread Marcone via Digitalmars-d-learn

On Tuesday, 19 January 2021 at 14:20:06 UTC, Imperatorn wrote:

On Tuesday, 19 January 2021 at 11:10:25 UTC, Marcone wrote:

On Tuesday, 19 January 2021 at 06:25:31 UTC, Imperatorn wrote:

On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote:
How can I create a Standalone Bundle Portable file 
application using Dlang?


Could you describe what you mean with "Bundle portable file 
application"?


All dependencies inside an exe file. Like Python Pyinstaller.


Do you with "dependencies" mean "resources"? In that case, yeah 
import is an option someone mentioned.


I do not mean resources .res, except if is possible use files 
inside resources without copy to hard disc and make accessible as 
it is in local path.


Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-19 Thread Marcone via Digitalmars-d-learn

On Tuesday, 19 January 2021 at 06:25:31 UTC, Imperatorn wrote:

On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote:
How can I create a Standalone Bundle Portable file application 
using Dlang?


Could you describe what you mean with "Bundle portable file 
application"?


All dependencies inside an exe file. Like Python Pyinstaller.


Why D functions paramter can not implicit infer type of Variant?

2021-01-13 Thread Marcone via Digitalmars-d-learn

import std;

void a(int b){
}

void main()
{
  Variant c = 10;
  a(c); // Error
}

Need more sugar.


Why many programmers don't like GC?

2021-01-13 Thread Marcone via Digitalmars-d-learn
I've always heard programmers complain about Garbage Collector 
GC. But I never understood why they complain. What's bad about GC?


Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-24 Thread Marcone via Digitalmars-d-learn

On Sunday, 24 January 2021 at 02:34:15 UTC, Jack wrote:

On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote:
How can I create a Standalone Bundle Portable file application 
using Dlang?


What are the dependencies that you would like to merge into 
executable? dlls? resources?


Qt5 Dll's or Tk dlls.


Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-24 Thread Marcone via Digitalmars-d-learn

On Saturday, 23 January 2021 at 21:26:28 UTC, James Blachly wrote:

On 1/20/21 6:50 AM, Marcone wrote:

On Tuesday, 19 January 2021 at 14:20:06 UTC, Imperatorn wrote:

On Tuesday, 19 January 2021 at 11:10:25 UTC, Marcone wrote:
On Tuesday, 19 January 2021 at 06:25:31 UTC, Imperatorn 
wrote:

On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote:
How can I create a Standalone Bundle Portable file 
application using Dlang?


Could you describe what you mean with "Bundle portable file 
application"?


All dependencies inside an exe file. Like Python Pyinstaller.


Do you with "dependencies" mean "resources"? In that case, 
yeah import is an option someone mentioned.


I do not mean resources .res, except if is possible use files 
inside resources without copy to hard disc and make accessible 
as it is in local path.


I am afraid we are not speaking the same language.

Because it sounds like you may not be using "dependencies" as 
it is conventionally understood in most programming 
communities, you'll need to give examples.


For the record, dependencies are typically either compile-time 
dependencies or run-time dependencies, and in both cases I 
think the commonest example would be a library.


Qt5 dlls


What is the difference between "delegate()" and "lazy delegate()" ?

2021-01-02 Thread Marcone via Digitalmars-d-learn

Why "lazy delegate()" need two parentheses to execute function?


Why there is no support for Dlang to convert Qt Creator .ui file to Dlang .d for use with QtE5?

2021-01-01 Thread Marcone via Digitalmars-d-learn
I have a GUI created using Qt Creator and save it to .ui file. I 
can convert .ui file to .cpp or .py (C++ or Python), but I can 
not convert .ui to .d for use with Dlang and QtE5.


My simple internet client made in Dlang.

2021-02-03 Thread Marcone via Digitalmars-d-learn
I study Dlang for just over a year only and have already risked 
creating a program even with a graphical interface and distribute 
it on the internet. Here is a part of that program, just the code 
without a graphical interface. It is a program for modifying http 
headers. You connect your program to the local port of this 
script, this script plays the role of a server to receive your 
program. Receive the HTTP request from the program, connect to 
the remote server playing a client role, modify the HTTP request 
from the program and connect to the remote server.



I would like the completely relevant opinion of you my programmer 
friends in Dlang if my code is good or if it is very noob.


My Code: 
https://github.com/cerejavermelha/Dlang-Client-Server-Socket-Dropbear-Injector/blob/master/Dlang_Client_Server_Socket_Dropbear_Injector.d


There are some Feed RSS or mail alert for new Dlang compiler update?

2021-06-12 Thread Marcone via Digitalmars-d-learn

Becouse I can not find it.


There are some Feed RSS or mail alert for new Dlang compiler update?

2021-06-13 Thread Marcone via Digitalmars-d-learn

Thank you very much guys.


Re: Why std.file.append() new lind "\n" not work in Windows?

2021-06-09 Thread Marcone via Digitalmars-d-learn

std.file.append(file, "\nApple");
std.file.append(file, "\nBanana");

Result:

AppleBanana



Why std.file.append() new lind "\n" not work in Windows?

2021-06-09 Thread Marcone via Digitalmars-d-learn

std.file.append("file; \nApple");
std.file.append("file; \nBanana");

Result:

AppleBanana


Re: Why std.file.append() new lind "\n" not work in Windows?

2021-06-09 Thread Marcone via Digitalmars-d-learn

std.file.append(file; "\nApple");
std.file.append(file; "\nBanana");

Result:

AppleBanana




How use lineSplitter with KeepTerminator flag?

2021-06-09 Thread Marcone via Digitalmars-d-learn

I want add Yes.keepTerminator flag on lineSplitter.


How use Predicate (alias pred = "a*b")?

2021-05-13 Thread Marcone via Digitalmars-d-learn

import std;

template foo(alias pred = "a*b"){
void foo(int x, int y){
writeln(x.unaryFun!pred);
}
}

void main(){
foo(5, 4);
}


"a" works, but "b" not work.
I get this error: Error: undefined identifier `b`



Re: How use Predicate (alias pred = "a*b")?

2021-05-13 Thread Marcone via Digitalmars-d-learn

On Thursday, 13 May 2021 at 21:38:25 UTC, Adam D. Ruppe wrote:

On Thursday, 13 May 2021 at 21:30:43 UTC, Marcone wrote:

template foo(alias pred = "a*b"){
void foo(int x, int y){
writeln(x.unaryFun!pred);


First, you really shouldn't use these at all. instead of a 
string, just pass an actual function to the thing as the 
predicate.


but if you must use it, unaryFun has one argument, so just a. 
if you want a and b, two arguments, that's binaryFun.


This is just a simple example of how it works. I won't use it. 
However, I believe it will be very useful for meta programming.


Re: How use Predicate (alias pred = "a*b")?

2021-05-13 Thread Marcone via Digitalmars-d-learn

On Thursday, 13 May 2021 at 21:38:25 UTC, Adam D. Ruppe wrote:

On Thursday, 13 May 2021 at 21:30:43 UTC, Marcone wrote:

template foo(alias pred = "a*b"){
void foo(int x, int y){
writeln(x.unaryFun!pred);


First, you really shouldn't use these at all. instead of a 
string, just pass an actual function to the thing as the 
predicate.


but if you must use it, unaryFun has one argument, so just a. 
if you want a and b, two arguments, that's binaryFun.


Thank you. binaryFun solved the problem.


Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Marcone via Digitalmars-d-learn

On Sunday, 16 May 2021 at 15:43:51 UTC, Adam D. Ruppe wrote:

On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote:

Error: undefined identifier 'SetDCBrushColor'


Did you include gdi32.lib on the command line?


I got this error:
C:\Users\Usuario\Arquivos\dm\lib\gdi32.lib
 Error 43: Not a Valid Library File


How suppress DMC File name and path showing after compile?

2021-05-06 Thread Marcone via Digitalmars-d-learn

dmc Programa.cpp && Programa.exe

is showing this, but I want show only "Hello World!"


C:\Users\Usuario\Arquivos\Estudando\C\Programa.cpp: <--- I don't 
want DMC show this.

Hello World!
[Finished in 0.2s]


Re: How suppress DMC File name and path showing after compile?

2021-05-06 Thread Marcone via Digitalmars-d-learn

On Thursday, 6 May 2021 at 16:00:03 UTC, Paul Backus wrote:

On Thursday, 6 May 2021 at 15:55:07 UTC, Marcone wrote:

dmc Programa.cpp && Programa.exe

is showing this, but I want show only "Hello World!"


C:\Users\Usuario\Arquivos\Estudando\C\Programa.cpp: <--- I 
don't want DMC show this.

Hello World!
[Finished in 0.2s]


Redirect the compiler's output to NUL:

https://docs.microsoft.com/en-US/troubleshoot/cpp/redirecting-error-command-prompt


I don't want redirect output to nul. Becouse errors in dmc is not 
redirected to stderror, so I will not see errors.


Can the DMC completely replace the C or C ++ compiler?

2021-05-06 Thread Marcone via Digitalmars-d-learn
Well, I am writing a C++ program and compiling with DMC Digital 
Mars, and the program is running normally. Can the DMC completely 
replace the C or C ++ compiler?





Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-17 Thread Marcone via Digitalmars-d-learn

Why gdi32.lib in dmc is not a Valid Library File?


Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Marcone via Digitalmars-d-learn

On Sunday, 16 May 2021 at 15:43:51 UTC, Adam D. Ruppe wrote:

On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote:

Error: undefined identifier 'SetDCBrushColor'


Did you include gdi32.lib on the command line?


Yes, I did it. But not work. I get this error:
Error: undefined identifier 'SetDCBrushColor'


Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Marcone via Digitalmars-d-learn

On Sunday, 16 May 2021 at 18:06:40 UTC, Jack wrote:

On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote:
Well, I program in D as a hobby for just over a year, and I 
like to learn and explore this wonderful programming language. 
Now I found the DMC compiler that compiles C ++ code. So I 
decided to test it. Creating a program with a win32api 
graphical interface I run into this error:


Error: undefined identifier 'SetDCBrushColor'

How to solve this problem? Thanks.


if it's not one defined in one of the core.sys.windows module, 
export it yourself:


```d
pragma(lib, "Gdi32.lib");

COLORREF SetDCBrushColor(
  HDC  hdc,
  COLORREF color
);

```


Not DMD + D, but DMC + C++


DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Marcone via Digitalmars-d-learn
Well, I program in D as a hobby for just over a year, and I like 
to learn and explore this wonderful programming language. Now I 
found the DMC compiler that compiles C ++ code. So I decided to 
test it. Creating a program with a win32api graphical interface I 
run into this error:


Error: undefined identifier 'SetDCBrushColor'

How to solve this problem? Thanks.


Re: Can the DMC completely replace the C or C ++ compiler?

2021-05-06 Thread Marcone via Digitalmars-d-learn

On Thursday, 6 May 2021 at 20:10:29 UTC, Adam D. Ruppe wrote:

On Thursday, 6 May 2021 at 19:59:01 UTC, Marcone wrote:
Well, I am writing a C++ program and compiling with DMC 
Digital Mars, and the program is running normally. Can the DMC 
completely replace the C or C ++ compiler?


It IS a C and C++ compiler.


Is it compatible with C++ 17 or 20? Can I delete my MinGW and use 
only DMC for any project in C or C++?


Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread Marcone via Digitalmars-d-learn

On Thursday, 27 May 2021 at 01:17:44 UTC, someone wrote:

Yes, I know this is a question lacking a straightforward answer.

Requirements:

[...]


Win32Api. You can use resEdit to create your resource GUI. Work 
only for Windows. Here is my program created with Dlang and 
Win32Api GUI:   
https://sourceforge.net/projects/direct-http-tunnel/


Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread Marcone via Digitalmars-d-learn

On Friday, 28 May 2021 at 17:04:15 UTC, Vinod K Chandran wrote:

On Thursday, 27 May 2021 at 01:17:44 UTC, someone wrote:


I am learning D by writing a Windows only GUI library. It is 
taking too much time for me since, I am writing some stuff and 
then happen to learn some new things about it and re-writing 
it.Anyhow, so far so good. This is the code now.


```d
import winglib ;
import std.stdio : log = writeln;

void main() {   

auto frm = new Window() ;   
frm.text = "Learning D By Writing D";

// C = Control class. Window is derived from Control
// E = EventArgs.

	frm.onMouseHover = (c, e) => log("Mouse is now on ", e.x, ", 
", e.y);

frm.onMouseLeave = (c, e) => log("Mouse leaved from window") ; 
frm.onKeyDown =  (c, e) => log(e.keyCode, " key is pressed");
frm.create() ;

auto btn = new Button(frm) ;
btn.font.name = "Calibri" ;
btn.width = 150 ;
btn.text = "DMD Or LDC" ;
btn.font.size = 14 ;
btn.create() ;

frm.show() ;

}
```
I am slowly adding more features to this. Till now, Window & 
Button are completed.


Win32Api + Metaprogramming?


foreach: How start a foreach count with specific number?

2021-06-02 Thread Marcone via Digitalmars-d-learn

Example:

// --args "C:\Users\Usuario\Downloads\dist\Programa.exe"

import modulo;

void main(string[] args){
if (args.length >= 2)
{
string exePrincipal = args[1];
chdir(exePrincipal.dirName);

foreach(n, i; glob("*")){
print("{} DATA {}".format(n, i));
}
}
}

This print:

0 DATA icone.ico
1 DATA libgcc_s_dw2-1.dll
2 DATA libstdc++-6.dll
3 DATA libwinpthread-1.dll
4 DATA platforms
5 DATA Programa.d
6 DATA Programa.exe
7 DATA Programa.obj
8 DATA Programa.rc
9 DATA Programa.res
10 DATA Qt5Core.dll
11 DATA Qt5Gui.dll
12 DATA Qt5Widgets.dll
13 DATA qte5.d
14 DATA QtE5Widgets32.dll


But I don't want it starts with 0, but other number. How can I do 
it?


Re: How do I get the output of the time bash command?

2021-01-27 Thread Marcone via Digitalmars-d-learn

On Wednesday, 27 January 2021 at 09:35:21 UTC, Anthony wrote:


I'm trying to read the timed output of a pipeShell command but 
it only results in empty output.


Does anyone know why this is?


```
auto p = pipeShell("time ls");

foreach(str; p.stdout.byLine) {
writefln("%s",str);
}
```


writeln(executeShell("time ls")[1]);


How use WinUI with Dlang?

2021-03-31 Thread Marcone via Digitalmars-d-learn

There is a way for create modern windows GUI with WinUI and Dlang?


Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Marcone via Digitalmars-d-learn
Why can't I just use: import vibe.vibe; for import packages like 
Nim or Python? Why I still use DUB?




Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Marcone via Digitalmars-d-learn

On Monday, 29 March 2021 at 19:14:41 UTC, Andre Pany wrote:

On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote:
Why can't I just use: import vibe.vibe; for import packages 
like Nim or Python? Why I still use DUB?


In python you also have pip.

It is possible to use vibe.d (any dub package) without dub but 
you have a few manual steps involved.


Kind regards
Andre


I just want compile direct with DMD witout DUB.


Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Marcone via Digitalmars-d-learn

On Monday, 29 March 2021 at 19:14:41 UTC, Andre Pany wrote:

On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote:
Why can't I just use: import vibe.vibe; for import packages 
like Nim or Python? Why I still use DUB?


In python you also have pip.

It is possible to use vibe.d (any dub package) without dub but 
you have a few manual steps involved.


Kind regards
Andre


Python dont need pip for run script with imported module. Just 
need call python.


Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Marcone via Digitalmars-d-learn

On Monday, 29 March 2021 at 19:14:41 UTC, Andre Pany wrote:

On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote:
Why can't I just use: import vibe.vibe; for import packages 
like Nim or Python? Why I still use DUB?


In python you also have pip.

It is possible to use vibe.d (any dub package) without dub but 
you have a few manual steps involved.


Kind regards
Andre


Why DMD can't make automatic this few steps involved?


How Add DUB packages path to Dlang Linter to avoid Errors?

2021-04-07 Thread Marcone via Digitalmars-d-learn
When I import modules from dub im my SublimeText, D Linter show 
as errors.

Example:

7:8  error  dmd:Error  module `core` is in file 
'vibe\core\core.d' which cannot be read


How solve it?


Why DUB do not import local D modules dependencies?

2021-04-09 Thread Marcone via Digitalmars-d-learn

How make dub import local D modules (mymodule.d) dependencies?


<    1   2   3   >