Re: How static link dll msvcr120.dll?

2023-06-01 Thread Marcone via Digitalmars-d-learn

On Tuesday, 30 May 2023 at 05:18:11 UTC, novice2 wrote:

you cannot "static link dll", "d" in "dll" is "dynamic".
you can implicity or explicity load dll.

https://learn.microsoft.com/en-us/cpp/build/linking-an-executable-to-a-dll?view=msvc-170

may be you mean static link msvcr120.lib?
i am not windows guru, but you need msvcr120.lib (there is 2 
version of .lib - one small for use .dll and contain only 
reference to code in dll, other large, for static linking, 
contains all code).


to link mylib.lib you can use pragma(lib, "mylib.lib") in D 
code.


I linked msvcr120.lib, but the executable still ask for 
msvcr120.dll not found.


Re: How can I use Linker flags using DMD?

2023-05-29 Thread Marcone via Digitalmars-d-learn

On Monday, 29 May 2023 at 22:48:29 UTC, Ali Çehreli wrote:

On 5/29/23 07:29, Marcone wrote:

I want send flags to linker when using dmd.exe compiler.


-L does it. Yes, -L-L can happen. :)

  https://dlang.org/dmd-linux.html

Ali


Can you help me static link dll msvcr120.dll in my x64 dlang 
program?


Re: How static link dll msvcr120.dll?

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

On Friday, 26 May 2023 at 12:29:15 UTC, Marcone wrote:

How can I static link msvcr120.dll using dmd?


Please, could someone tell me if it is possible to link the 
msvcr120.dll library to the program's executable using the dmd 
compiler? Because I would like my program to remain portable.


Re: How make a Dlang with Windows GUI x64 without console?

2023-05-26 Thread Marcone via Digitalmars-d-learn

On Friday, 26 May 2023 at 19:17:28 UTC, John Chapman wrote:

On Friday, 26 May 2023 at 18:05:38 UTC, Marcone wrote:
How can I hide console of a window GUI on Windows x64? I need 
run with -m64


-L/SUBSYSTEM:Windows

And if you're using 'main' as the entry point rather than 
'WinMain':


-L/ENTRY:mainCRTStartup


It need msvcrt120.dll but I don't know how static link 
msvcrt120.lib


Re: How make a Dlang with Windows GUI x64 without console?

2023-05-26 Thread Marcone via Digitalmars-d-learn

On Friday, 26 May 2023 at 19:15:16 UTC, ryuukk_ wrote:

On Friday, 26 May 2023 at 18:05:38 UTC, Marcone wrote:
How can I hide console of a window GUI on Windows x64? I need 
run with -m64


Someone asked the exact same thing yesterday, check their post: 
https://forum.dlang.org/thread/azlraopxmidtcdmnr...@forum.dlang.org



```
"lflags-windows": [
"/SUBSYSTEM:windows",
],
```


It need msvcrt120.dll but I don't know how static link 
msvcrt120.lib


How static link dll msvcr120.dll?

2023-05-26 Thread Marcone via Digitalmars-d-learn

How can I static link msvcr120.dll using dmd?


What do you think about using Chat GPT to create functions in D?

2023-04-03 Thread Marcone via Digitalmars-d-learn
What do you think about using Chat GPT to create functions in D? 
I asked Chat-GPT to create a function in D that was similar to 
the rsplit() function in Python. It returned this code to me:



import std.algorithm;
import std.array;
import std.string;

string[] rsplit(string input, string separator, size_t maxsplit = 
size_t.max) {

auto splitter = splitter(input, separator, SplitterFlag.all);
auto results = splitter.array;
if (maxsplit < results.length - 1)
results = results[results.length - maxsplit - 1 .. $];
return results;
}



Re: ePub/Mobi/AZW3/PDF of Phobos Runtime Library

2022-06-28 Thread Marcone via Digitalmars-d-learn
Is there any way to do this automatically like Python? 
https://docs.python.org/3/download.html


Re: ePub/Mobi/AZW3/PDF of Phobos Runtime Library

2022-06-28 Thread Marcone via Digitalmars-d-learn

On Tuesday, 28 June 2022 at 20:38:10 UTC, forkit wrote:

On Tuesday, 28 June 2022 at 18:42:11 UTC, Marcone wrote:

[...]


So assuming i understand what you're asking for here, it 
already exists.


When you download D, you get a directory named 'html'.

In that directory is a file named 'index.html'.

Is that what you want? (see the Documentation menu at the top 
of the index.html)


The only problem with that, is that it downloads fonts, so you 
need access to the internet. It will still work fine without 
access, but it will default to a font that isn't particulary 
nice on the eyes.


I wish I could read D's entire Phobos library on my Kindle ebook 
reader.


Re: ePub/Mobi/AZW3/PDF of Phobos Runtime Library

2022-06-28 Thread Marcone via Digitalmars-d-learn
On Tuesday, 28 June 2022 at 19:06:48 UTC, Steven Schveighoffer 
wrote:

On 6/28/22 2:42 PM, Marcone wrote:

[...]


We used to have this, it wasn't used, and keeping it building 
was a drain on resources. What is wrong with the online docs? 
What dissemination do you think could happen if we had it in 
these formats that's going to reach people more than the HTML 
version?


Note that the zipfile has a complete copy of the documentation 
in html format.


-Steve


I wish I could read all the documentation for D on my Kindle 
ebook reader.


ePub/Mobi/AZW3/PDF of Phobos Runtime Library

2022-06-28 Thread Marcone via Digitalmars-d-learn

Beloved,


I love programming in D. D is my favorite programming language. 
I'm not a professional programmer, but I love to program. I would 
like to learn D deeply. Most programming languages have a 
PDF/CHM/MOBI/ePub version of the standard library. But D still 
doesn't have such a portable version of the Phobos Runtime 
Library. I humbly ask you to make available a portable version of 
the Phobos library, to better disseminate the D programming 
language.



Thank you


Re: UI Library

2022-06-10 Thread Marcone via Digitalmars-d-learn

On Friday, 20 May 2022 at 02:37:48 UTC, harakim wrote:
I need to write a piece of software to track and categorize 
some purchases. It's the kind of thing I could probably write 
in a couple of hours in C#/Java + html/css/javascript. However, 
something keeps drawing me to D and as this is a simple 
application, it would be a good one to get back in after almost 
a year hiatus.


[...]


Qt Creator + Dlang: https://youtu.be/TFN5P4eoS_o


Re: UI Library

2022-06-10 Thread Marcone via Digitalmars-d-learn

On Friday, 20 May 2022 at 02:37:48 UTC, harakim wrote:
I need to write a piece of software to track and categorize 
some purchases. It's the kind of thing I could probably write 
in a couple of hours in C#/Java + html/css/javascript. However, 
something keeps drawing me to D and as this is a simple 
application, it would be a good one to get back in after almost 
a year hiatus.


[...]


QtE5
https://github.com/MGWL/QtE5


Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-26 Thread Marcone via Digitalmars-d-learn

On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote:

On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:


I am using a main() function.
I am compiling on Windows x86 32 bits.
I am using DMD 2.100.0
This error is only in version 2.100.0 of DMD.


Did you try 2.099 too? Because the default build mode for 32bit 
was changed to MS-COFF and it smells a litte bit that you have 
used OMF before. MS-COFF format inserts the reference to the 
C-runtime library automatically.


Try the -m32omf switch.


I tried compiling now on x64 without console using 
-L/SUBSYSTEM:windows user32.lib -L/entry:mainCRTStartup -m64 and 
it doesn't work. It compiles, but the program does not run 
afterwards. I also tried to add -m32omf But in this case the 
compilation error. How to solve this?


Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-20 Thread Marcone via Digitalmars-d-learn

On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote:

On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:


I am using a main() function.
I am compiling on Windows x86 32 bits.
I am using DMD 2.100.0
This error is only in version 2.100.0 of DMD.


Did you try 2.099 too? Because the default build mode for 32bit 
was changed to MS-COFF and it smells a litte bit that you have 
used OMF before. MS-COFF format inserts the reference to the 
C-runtime library automatically.


Try the -m32omf switch.


Now work fine! Thank you.


Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Marcone via Digitalmars-d-learn

On Thursday, 19 May 2022 at 22:13:06 UTC, Adam Ruppe wrote:

On Thursday, 19 May 2022 at 21:41:50 UTC, Marcone wrote:
Are you using the `-L/entry:mainCRTStartup` or the 
`L/entry:wmainCRTStartup` ?


-L/entry:mainCRTStartup


try the w one too. both doing the same result?


Both is doing the same result.


Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Marcone via Digitalmars-d-learn

On Thursday, 19 May 2022 at 20:33:34 UTC, Adam D Ruppe wrote:

On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:

I am using a main() function.
I am compiling on Windows x86 32 bits.
I am using DMD 2.100.0
This error is only in version 2.100.0 of DMD.


Are you using the `-L/entry:mainCRTStartup` or the 
`L/entry:wmainCRTStartup` ?


-L/entry:mainCRTStartup


Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Marcone via Digitalmars-d-learn

On Thursday, 19 May 2022 at 19:35:20 UTC, Adam D Ruppe wrote:

On Thursday, 19 May 2022 at 19:29:25 UTC, Marcone wrote:

Using -L/SUBSYSTEM:windows user32.lib


you using a main() function right?

Please note when compiling on Win64, you need to explicitly 
list -Lgdi32.lib -Luser32.lib on the build command. If you want 
the Windows subsystem too, use -L/subsystem:windows 
-L/entry:mainCRTStartup.


If using ldc instead of dmd, use -L/entry:wmainCRTStartup 
instead of mainCRTStartup; note the "w".



see some deets i wrote here

http://arsd-official.dpldocs.info/arsd.simpledisplay.html#installation-instructions


I am using a main() function.
I am compiling on Windows x86 32 bits.
I am using DMD 2.100.0
This error is only in version 2.100.0 of DMD.


Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Marcone via Digitalmars-d-learn

Using -L/SUBSYSTEM:windows user32.lib

Error:

lld-link: error: undefined symbol: _WinMain@16
referenced by 
msvcrt120.lib(msvcrt_stub2.obj):(_WinMainCRTStartup)

Error: linker exited with status 1


Re: QtE56: QFormBuilder: Error: undefined identifier `QFormBuilder`

2022-04-28 Thread Marcone via Digitalmars-d-learn

On Thursday, 28 April 2022 at 07:02:14 UTC, MGW wrote:

Probably did not compile
QtE5-master/build/QtE56/qte56core.pro
QtE5-master/build/QtE56/qte56widgets.pro
Use QMAKE to build a DLL/SO

More details by mail: m...@yandex.ru


I sent you an email. Could you answer me and send me these dlls 
for Windows x64? Thanks.





Re: QtE56: QFormBuilder: Error: undefined identifier `QFormBuilder`

2022-04-28 Thread Marcone via Digitalmars-d-learn

On Thursday, 28 April 2022 at 07:02:14 UTC, MGW wrote:

Probably did not compile
QtE5-master/build/QtE56/qte56core.pro
QtE5-master/build/QtE56/qte56widgets.pro
Use QMAKE to build a DLL/SO

More details by mail: m...@yandex.ru


Hi, I didn't compile it as Qt is too big for me to download just 
to use qmake to create these dlls. Could you please help all of 
us by making these dlls compiled for Windows x64 available? Thank 
you very much.


QtE56: QFormBuilder: Error: undefined identifier `QFormBuilder`

2022-04-26 Thread Marcone via Digitalmars-d-learn
I'm trying to load a .ui GUI designed in Qt Designer. I'm 
following the examples in the links below, but the following 
error occurs: Error: undefined identifier `QFormBuilder`



QFormBuilder qfb = new QFormBuilder(this);
setQtObj((qfb.load(":/fQtE56help.ui")).QtObj);


* https://github.com/MGWL/QtE5/

* https://github.com/MGWL/QtE5/wiki

* https://github.com/MGWL/QtE5/wiki

* https://www.youtube.com/watch?v=TFN5P4eoS_o

Could anyone help me to solve the problem? I would like to design 
my GUI in Qt Designer, and load the .ui to create my program.


Re: DUB issues

2022-04-18 Thread Marcone via Digitalmars-d-learn
The dub creator shouldn't even remember creating this anymore. It 
makes me sad when I see that things in D are old, forgotten, 
outdated, abandoned. D is the best programming language in the 
world. But nobody appreciates it. It makes me sad when I see the 
repositories for over 10 years without an update, most things in 
dub are for Dlang 1 still.


Re: Where I download Digital Mars C Preprocessor sppn.exe?

2022-04-02 Thread Marcone via Digitalmars-d-learn
ImportC is deprecated as everything in D is deprecated and 
abandoned. No link works, every download link is broken as no one 
cares. All D code is always full of bugs and needs to be 
corrected by the user before trying to run it, in order to 
realize that it wasted time.


https://dlang.org/spec/importc.html


Where I download Digital Mars C Preprocessor sppn.exe?

2022-04-02 Thread Marcone via Digitalmars-d-learn
Where I download Digital Mars C Preprocessor sppn.exe? I need it 
to use ImportC


Why exe size change if import entire std or just writeln?

2022-03-23 Thread Marcone via Digitalmars-d-learn

import std.stdio : writeln;

void main(){
writeln("Bom dia");
}


Size exe file: 258 KB

--

import std;

void main(){
writeln("Bom dia");
}

Size exe file: 595 KB



If dependencies are resolved at compile time, why does the 
compiler include extra stuff?


How can I implement SSL protocol in my program?

2022-03-22 Thread Marcone via Digitalmars-d-learn

/*
Direct DropBear Dlang Injector.
Created by Marcone (thegrapev...@email.com) in 2019.
*/

import std;
import core.thread;
import core.stdc.stdlib;

// Configuracoes.
string LISTEN_PORT = "127.0.0.1:8088";
string PAYLOAD = "GET / HTTP/1.1\r\nhost: www.bing.com\r\n\r\n";

void conecta(Socket c, int conn_number){

writeln("\nConnection #", conn_number);
writeln("[#] Received Client.");

char[8192] request;
auto rq = c.receive(request);

string host = 
to!string(request)[to!string(request).indexOf("CONNECT")+7..to!string(request).indexOf(":")].strip();
ushort port = 
to!ushort(to!string(request)[to!string(request).indexOf(":")+1..to!string(request).indexOf("HTTP/")].strip());


writeln("[-] Real request: \"", 
to!string(request[0..rq]).replace("\r\n", r"\r\n"), "\"");
writeln("[#] Payload: \"", PAYLOAD.replace("\r\n", 
r"\r\n"), "\"");


auto s = new Socket(AddressFamily.INET, 
SocketType.STREAM);

s.blocking = true;
writeln("[-] Direct connection to server: ", host, ":", 
port);

try{
s.connect(new InternetAddress(host, port));
}catch(Exception){
writeln("[!] Error when try to connect to server: ", 
host, ":", port);

}

s.send(PAYLOAD); // Payload.
c.send("HTTP/1.1 200 Established\r\n\r\n");

auto set = new SocketSet();
char[8192] data;

while(true){
set.reset();
set.add(s);
set.add(c);
Socket.select(set, null, null, null);

if (set.isSet(s)){
// Download
auto got = s.receive(data);
if (got == 0){break;}
c.send(data[0 .. got]);
} else {
// Upload
auto got = c.receive(data);
if (got == 0){break;}
s.send(data[0 .. got]);
}
}
writeln("[!] Client Disconnected!");
writeln("[!] Connection #%d Closed!".format(conn_number));
}

void main(){
spawnShell("title Direct DropBear Dlang Injector && color 
47");
	writeln("-*-*-*- Direct DropBear Dlang Injector 
-*-*-*-\nCreated by Marcone (thegrapev...@email.com) in 2019\n");


int conn_number = 0;

// Listen
auto l = new Socket(AddressFamily.INET, SocketType.STREAM);
try {
l.bind(new 
InternetAddress(LISTEN_PORT[0..LISTEN_PORT.indexOf(":")], 
to!ushort(LISTEN_PORT[LISTEN_PORT.indexOf(":")+1..LISTEN_PORT.length])));

l.blocking = true;
} catch(Exception){
writeln("[!] Listen Error! Listen Port ", 
LISTEN_PORT, " is alread in Use!" );

readln();
exit(1);
}
l.listen(1);
writeln("[-] Listening on IP and Port: ", 
LISTEN_PORT[0..LISTEN_PORT.indexOf(":")], ":", 
LISTEN_PORT[LISTEN_PORT.indexOf(":")+1..LISTEN_PORT.length], 
"\n");


while(true){
conn_number += 1;
task!conecta(l.accept(), 
conn_number).executeInNewThread();

}
}


Re: I like dlang but i don't like dub

2022-03-22 Thread Marcone via Digitalmars-d-learn
Why is dmd unable to import modules installed by dub using the 
import command like it does with the Phobos library? He can't 
send these modules to Linker? Needing to be passed to dmd via 
command line. I think it could be all automatic.


Re: I like dlang but i don't like dub

2022-03-21 Thread Marcone via Digitalmars-d-learn
The DMD compiler could import the modules directly with the 
import command just like it does with the modules in the phobos 
library.


Re: Example of Windows SSL with Secure Channel?

2022-03-21 Thread Marcone via Digitalmars-d-learn
I hope one day the creators of the D programming language will 
implement std.socket.ssl ​​in the Phobos library.


std.signals: Why emit() not extist?

2021-12-30 Thread Marcone via Digitalmars-d-learn
I get this error: Error: undefined identifier `emit`, did you 
mean function `exit`?


Re: Why can't the DMD compiler accept files or directories with white spaces even delimited by quotes?

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

On Sunday, 5 September 2021 at 00:00:33 UTC, jfondren wrote:

On Saturday, 4 September 2021 at 23:50:33 UTC, Marcone wrote:

Example:

dmd "hello world.d"


```
$ cat hello\ world.d
module helloworld;
void main() {
import std.stdio : writeln;
writeln("without the explicit 'module', this file would");
writeln("be inferred to have an invalid module name.");
}
$ dmd 'hello world.d'
$ ./hello\ world
without the explicit 'module', this file would
be inferred to have an invalid module name.
$ sed -i 1d hello\ world.d
$ dmd 'hello world.d'
hello world.d: Error: module `hello world` has non-identifier 
characters in filename, use module declaration instead

```


Very Good! Now work fine.


Why can't the DMD compiler accept files or directories with white spaces even delimited by quotes?

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

Example:

dmd "hello world.d"


Re: how to import .lib library

2021-08-15 Thread Marcone via Digitalmars-d-learn

On Sunday, 15 August 2021 at 10:12:17 UTC, Timofeyka wrote:

Thank you for your reply!
I wanted to link to my project another project without source 
code.


This tutorial can help you create yours libs: 
https://wiki.dlang.org/Win32_DLLs_in_D


Re: how to import .lib library

2021-08-15 Thread Marcone via Digitalmars-d-learn

On Sunday, 15 August 2021 at 09:49:39 UTC, Timofeyka wrote:

Hello!
I may have a very stupid question, but still.
How do I include a .lib library? How to use it in your code?


Inside the source code you can use pragma. Example:

pragma(lib, "gdi32.lib");

In DMD command line you can use -L flag that pass the lib to 
linker. Example:


dmd -Lgdi32.lib mycode.d


Re: How to extend the string class to return this inside the square bracket?

2021-08-14 Thread Marcone via Digitalmars-d-learn

On Saturday, 14 August 2021 at 08:24:41 UTC, user1234 wrote:

On Friday, 13 August 2021 at 23:33:05 UTC, Paul Backus wrote:

On Friday, 13 August 2021 at 23:23:55 UTC, Marcone wrote:


writeln("Hello World!"[x.indexOf("e")..x.indexOf("r")]);

indexOf()is just a simple example, not the goal. I want 
handle literal inside [] like it bellow, but in literal:


string x = "Hello World!";
writeln(x[x.indexOf("e")..x.indexOf("r")]);


You can use the `pipe` function to bind an arbitrary 
expression to a variable:


```d
import std.functional: pipe;
import std.algorithm: countUntil;
import std.stdio: writeln;

"Hello world!"
.pipe!(s => s[s.countUntil('e') .. s.countUntil('r')])
.writeln;
```


nice, that's the best alternative.


Very Good!!! This pipe!() is just what I am looking for. Thank 
you very much


Re: How to extend the string class to return this inside the square bracket?

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

On Friday, 13 August 2021 at 23:21:42 UTC, Ali Çehreli wrote:

On 8/13/21 4:08 PM, jfondren wrote:

On Friday, 13 August 2021 at 22:09:59 UTC, Marcone wrote:


Isn't there some unario operator template that I can use with 
lambda to handle a string literal?


So, something other than an exact "lit"[0..this.xx(..)] syntax 
is fine?


What didn't you like about `"Hello 
World!".findSplit("o")[0].writeln;` then?


What is a real example of something you want to do?


And I started writing the following but stopped because the 
semantics are not clear. I first called it 'between' but then 
should the 'o' that was searched be a part of the output?


Should "from 'o' to 'o'" produce an empty string, should it 
include a single 'o' or should it go all the way to the next 
'o'?


What about the last line which says "from 'd' to 'a'"? Is that 
an entirely empty range or just 'd' or 'd' till the end?


I don't think the programming language can decide one way or 
the other.


import std.algorithm;
import std.range;
import std.stdio;

auto inclusive(R, E)(R range, E fromNeedle, E toNeedle) {
  auto found = range.find(fromNeedle);
  return chain(found.front.only, 
found.drop(1).findSplitAfter(only(toNeedle))[0]);

}

void main() {
  const s = "Hello World!";
  auto r = s.inclusive('o', 'o');
  writeln(r);

  writeln("abcdef".inclusive('d', 'a'));
}

Ali



import std;

class None {}
// Function 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];}

}

void main(){
writeln("Hello World!".slice(1, 8)); // ello Wo
writeln("Hello World!".slice("e", "r")); // ello Wo
writeln("Hello World!".slice(1, "r")); // ello Wo
writeln("Hello World!".slice("e", 8)); // ello Wo
writeln("Hello World!".slice(6, -1)); // World (Same as $-1)
	writeln("Hello World!".slice(-12, -7)); // Hello (Same as $-12, 
$-7)
	writeln("Hello World!".slice("W", -1)); // World (Same as "W", 
$-1)
	writeln("Hello World!".slice(-12, " ")); // Hello (Same as $-12, 
" ")

}

Like this function, but inside []. So I can use functions to get 
index for slice.





Re: How to extend the string class to return this inside the square bracket?

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

On Friday, 13 August 2021 at 23:08:07 UTC, jfondren wrote:

On Friday, 13 August 2021 at 22:09:59 UTC, Marcone wrote:


Isn't there some unario operator template that I can use with 
lambda to handle a string literal?


So, something other than an exact "lit"[0..this.xx(..)] syntax 
is fine?


What didn't you like about `"Hello 
World!".findSplit("o")[0].writeln;` then?


What is a real example of something you want to do?


writeln("Hello World!"[x.indexOf("e")..x.indexOf("r")]);

indexOf()is just a simple example, not the goal. I want handle 
literal inside [] like it bellow, but in literal:


string x = "Hello World!";
writeln(x[x.indexOf("e")..x.indexOf("r")]);


Re: How to extend the string class to return this inside the square bracket?

2021-08-13 Thread Marcone via Digitalmars-d-learn
On Friday, 13 August 2021 at 21:47:22 UTC, Steven Schveighoffer 
wrote:

On 8/13/21 5:05 PM, Marcone wrote:
How to extend the string class to return this inside the 
square bracket the same way opDollar $ returns the length of 
the string? Thank you.


     import std;

     void main(){
     writeln("Hello World!"[0..this.indexOf("o")]);
     }


There is no string class to extend.

`$` is a special token the compiler changes to `arr.length` for 
arrays.


-Steve


Isn't there some unario operator template that I can use with 
lambda to handle a string literal?


Re: How to extend the string class to return this inside the square bracket?

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

On Friday, 13 August 2021 at 21:14:29 UTC, user1234 wrote:

On Friday, 13 August 2021 at 21:05:22 UTC, Marcone wrote:
How to extend the string class to return this inside the 
square bracket the same way opDollar $ returns the length of 
the string? Thank you.


import std;

void main(){
writeln("Hello World!"[0..this.indexOf("o")]);
}


this does not exist (and see few reason for) but algo + ufcs 
allows this easily, e.g


```
"Hello World!".findSplit("o")[0].writeln;
```

bonus: both can throw bound error


My example was just an example. I don't want this solution. I 
want to have the power to handle the string inside the square 
brackets.


How to extend the string class to return this inside the square bracket?

2021-08-13 Thread Marcone via Digitalmars-d-learn
How to extend the string class to return this inside the square 
bracket the same way opDollar $ returns the length of the string? 
Thank you.


import std;

void main(){
writeln("Hello World!"[0..this.indexOf("o")]);
}


Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Marcone via Digitalmars-d-learn

On Tuesday, 10 August 2021 at 19:01:42 UTC, Adam D Ruppe wrote:

On Tuesday, 10 August 2021 at 18:59:33 UTC, Marcone wrote:

Using -Lgdi32.lib -Luser32.lib? Same error.


The part after that:

If you want the Windows subsystem too, use -L/subsystem:windows 
-L/entry:mainCRTStartup.



Pass BOTH -L/subsystem:windows AND -L/entry:mainCRTStartup


Good! work very well! Thank you!


Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Marcone via Digitalmars-d-learn

On Tuesday, 10 August 2021 at 18:51:28 UTC, Adam D Ruppe wrote:

On Tuesday, 10 August 2021 at 18:45:35 UTC, Marcone wrote:
Hi, do you have some other solution without 
arsd.simpledisplay? I want only dmd feature.


Did you read the paragraph under the link? That IS a dmd 
switch. Or a ldc switch. It explains the concept which works 
with anything.


Using -Lgdi32.lib -Luser32.lib? Same error.


Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Marcone via Digitalmars-d-learn

On Tuesday, 10 August 2021 at 18:36:27 UTC, Adam D Ruppe wrote:

On Tuesday, 10 August 2021 at 18:34:03 UTC, Marcone wrote:

How can I hide console using -m64?


http://dpldocs.info/experimental-docs/arsd.simpledisplay.html#installation-instructions


Hi, do you have some other solution without arsd.simpledisplay? I 
want only dmd feature.


-L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Marcone via Digitalmars-d-learn
How use -L/SUBSYSTEM:windows for hide console in x64 prograns? 
Becouse if I use -L/SUBSYSTEM:windows and -m64 I get this error:


lld-link: error: undefined symbol: WinMain

referenced by msvcrt120.lib(msvcrt_stub2.obj):($LN5)

Error: linker exited with status 1

If I delete -L/SUBSYSTEM:windows compile fine.


How can I hide console using -m64?


Re: Error when compile with DMD using -m64?

2021-08-10 Thread Marcone via Digitalmars-d-learn

On Tuesday, 10 August 2021 at 15:55:42 UTC, Bastiaan Veelo wrote:

On Tuesday, 10 August 2021 at 01:29:04 UTC, Marcone wrote:

Solved converting long and int.


Use `size_t` and `ptrdiff_t` instead to make your program 
compile in both 32 bit and 64 bit modes.


https://dlang.org/spec/type.html#aliased-types

-- Bastiaan.


Thank you very much! Your information was very precious! It 
worked very well! Now I can create x32 or x64 compatible programs 
without creating two codes.


Re: Error when compile with DMD using -m64?

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

On Monday, 9 August 2021 at 19:58:03 UTC, novice2 wrote:

On Monday, 9 August 2021 at 19:53:48 UTC, Marcone wrote:

program not run.


compilation errors?
runtime errors?


Solved converting long and int.


Error when compile with DMD using -m64?

2021-08-09 Thread Marcone via Digitalmars-d-learn
When I compile program in Ly Windows x64 using dmd flag -m64 the 
program not run.

How fix it?


Re: How Add Local modules mymodule.d using DUB?

2021-08-09 Thread Marcone via Digitalmars-d-learn
On Monday, 9 August 2021 at 16:37:10 UTC, Steven Schveighoffer 
wrote:

On 8/9/21 12:32 PM, Marcone wrote:

My main program need import a local module called mymodule.d.
How can I add this module using DUB? Thank you.


You mean how to add a local project (that isn't on 
code.dlang.org)?


`dub add-local .` inside the project directory.

I don't think you can add a file directly without a project, 
but possibly.


-Steve


Add module to linker.


Re: How Add Local modules mymodule.d using DUB?

2021-08-09 Thread Marcone via Digitalmars-d-learn
On Monday, 9 August 2021 at 16:37:10 UTC, Steven Schveighoffer 
wrote:

On 8/9/21 12:32 PM, Marcone wrote:

My main program need import a local module called mymodule.d.
How can I add this module using DUB? Thank you.


You mean how to add a local project (that isn't on 
code.dlang.org)?


`dub add-local .` inside the project directory.

I don't think you can add a file directly without a project, 
but possibly.


-Steve


I want add modules as phobos modules, but custom modules.


How Add Local modules mymodule.d using DUB?

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

My main program need import a local module called mymodule.d.
How can I add this module using DUB? Thank you.


Re: How to divide by space keeping words with spaces inside quotes?

2021-08-09 Thread Marcone via Digitalmars-d-learn
Thank you very much! With your helps I created this function that 
works fine:


// Function splitcommas()
string[] splitcommas(string text) nothrow {
try {
		return 
text.splitter!(Yes.keepSeparators)(regex("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'")).array.map!(x => x.replace("\"", "")).filter!(x => x.strip.length).array;

} catch(Throwable){ return []; }
}


How to divide by space keeping words with spaces inside quotes?

2021-08-08 Thread Marcone via Digitalmars-d-learn

How to divide by space keeping words with spaces inside quotes?

Exanple:

string text = "Duck Cat \"Carl Rivers\" Dog";

I want split to:

["Duck", "Cat", "Carl Rivers", "Dog"]


ATENTION: I DON'T WANT:

["Duck", "Cat", "Carl", "Rivers", "Dog"]


How can I get it in Dlang?


Re: How suppress (Hide) prompt command console in DMC? Like -mwindows in C++?

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

On Sunday, 8 August 2021 at 00:23:55 UTC, Adam D Ruppe wrote:

On Sunday, 8 August 2021 at 00:02:18 UTC, Marcone wrote:
I create a gui program using DMC. I want to know how suppress 
(Hide) prompt command console in DMC? Like -mwindows in C++. 
Thank you.


use /subsystem:windows

a few more details here 
http://arsd-official.dpldocs.info/arsd.simpledisplay.html#installation-instructions


Thank you very much! Work fine.


How suppress (Hide) prompt command console in DMC? Like -mwindows in C++?

2021-08-07 Thread Marcone via Digitalmars-d-learn
I create a gui program using DMC. I want to know how suppress 
(Hide) prompt command console in DMC? Like -mwindows in C++. 
Thank you.


DMC Error: comctl32.lib Error 43: Not a Valid Library File

2021-08-07 Thread Marcone via Digitalmars-d-learn
Using DMC to compile .cpp using gdi32.lib as dmc compile 
parameter. I get this error:


OPTLINK (R) for Win32  Release 8.00.16
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
comctl32.lib
 Error 43: Not a Valid Library File
--- errorlevel 1


How can I solve it?


Re: DMC Error: comctl32.lib Error 43: Not a Valid Library File

2021-08-07 Thread Marcone via Digitalmars-d-learn
I added gdi32.lib user32.lib kernel32.lib comctl32.lib as dmc 
parameters. But don't work.


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.


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.


How use lineSplitter with KeepTerminator flag?

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

I want add Yes.keepTerminator flag on lineSplitter.


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




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: 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?


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: 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?


I got this error:
C:\Users\Usuario\Arquivos\dm\lib\gdi32.lib
 Error 43: 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 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++


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'


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: 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: 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.


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: 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++?


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: 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.


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: win64 DLL stdout printing after main process completes

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

On Monday, 19 April 2021 at 14:55:03 UTC, cc wrote:
I'm not sure if this is something unique to D or not, but I've 
having a minor issue where stdout output from a DLL (either via 
printf or phobos std.stdio write) is not displayed until after 
the main process has completed.  I'm making a project based 
around the example at https://wiki.dlang.org/Win32_DLLs_in_D 
which I've heard is a little out of date but I've gotten it 
working nonetheless.  I have the following project files:


```d
// mydll.d
module mydll;
import core.runtime;
import core.stdc.stdio;
import core.stdc.stdlib;
import core.sys.windows.windows;
extern(Windows) BOOL DllMain(HINSTANCE hInstance, ULONG 
ulReason, LPVOID pvReserved) {

switch (ulReason) {
case DLL_PROCESS_ATTACH:
printf("[dll] DLL_PROCESS_ATTACH\n");
Runtime.initialize();
break;
case DLL_PROCESS_DETACH:
printf("[dll] DLL_PROCESS_DETACH\n");
Runtime.terminate();
break;
case DLL_THREAD_ATTACH:
printf("[dll] DLL_THREAD_ATTACH\n");
return false;
case DLL_THREAD_DETACH:
printf("[dll] DLL_THREAD_DETACH\n");
return false;
default:
}
return true;
}
export int MyDLL_Test() {
printf("[dll] MyDLL_Test\n");
return 5;
}
static this() {
printf("[dll] static this for mydll\n");
}
static ~this() {
printf("[dll] static ~this for mydll\n");
}
```

```d
// mydll.di
module mydll;
export int MyDLL_Test();
```

```d
// main.d
import mydll;
pragma(lib, "mydll.lib");
import core.sys.windows.windows;
void main() {
printf("[Main] Start\n");
scope(exit) printf("[Main] END\n");
int x = MyDLL_Test();
printf("[Main] x: %d\n", x);
printf("[Main] Finished\n");
}
```

DLL compilation command line: `dmd -m64 -ofmydll.dll -L/DLL 
mydll.d mydll.def`

Main command line: `rdmd -m64 main.d`

And upon running, the output I receive is:
```
[Main] Start
[Main] x: 5
[Main] Finished
[Main] END
[dll] DLL_PROCESS_ATTACH
[dll] static this for mydll
[dll] MyDLL_Test
[dll] DLL_PROCESS_DETACH
[dll] static ~this for mydll
```

I would expect the first three lines of dll output to precede 
the "[Main] x:" line at least.  Is there something I'm doing 
wrong?  Do I need to somehow pass a reference to the main stdio 
to the DLL's D runtime similar to how the GC can be shared?


Hi, I use this function:

// Function echo()
void echo(T)(T text) nothrow {try {spawnShell("echo%s 
%s".format(text.to!string.strip() != "" ? "" : ".", 
text.to!string.replace(">","^>").replace("&","^&").replace("\n"," 
&"))); } catch(Throwable){} }


echo("This is not will wait the end to print.");


Re: How send parameters to DMD when using DUB

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

/+ dub.sdl:
   dependency "telega" version="~>0.2.0"
   lflags "C:\\Users\\Usuario\\Arquivos\\Sublime Text Build 
3211\\Data\\Packages\\resources.res" platform="dmd"

+/

Solved replaceing dflags to lflags



Re: How send parameters to DMD when using DUB

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

I'm trying this code but do not work.

/+ dub.sdl:
   dependency "telega" version="~>0.2.0"
   dflags "C:\\Users\\Usuario\\Arquivos\\Sublime Text Build 
3211\\Data\\Packages\\resources.res" platform="dmd"

+/


How send parameters to DMD when using DUB

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

I need add resources. But how can I make it using DUB?


Re: DUB Error with packcage dformlib

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

On Sunday, 18 April 2021 at 07:31:12 UTC, Imperatorn wrote:

On Sunday, 18 April 2021 at 01:37:14 UTC, Marcone wrote:

I have this message when try build dub. How solve it?

Unresolvable dependencies to package dformlib
app ~master depends on dformlib ~0.2.2>


Just a comment, dforms is millions of years old. It would be 
nice to see support for it again, but I would probably choose 
another framework.


Really. But in D everything is old and obsolete.


DUB Error with packcage dformlib

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

I have this message when try build dub. How solve it?

Unresolvable dependencies to package dformlib
app ~master depends on dformlib ~0.2.2>


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?


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?


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?


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?


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


I just want compile direct with DMD witout DUB.


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: How add png image to zip file using std.zip?

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

On Sunday, 21 February 2021 at 18:10:43 UTC, JN wrote:

On Sunday, 21 February 2021 at 17:17:56 UTC, Marcone wrote:

ZipArchive zip = new ZipArchive();
std.file.write("foo.zip", zip.build());

ArchiveMember f = new ArchiveMember();
f.name = "Wallpaper_001.png";

zip.addMember(f);
std.file.write("foo.zip", zip.build());

File is added with file size 0.
How can I use expandedData for add images files? Or what I use 
for it?


expandedData should hold the contents of the uncompressed file, 
as byte array. So something like:


f.name = "Wallpaper_001.png";
f.expandedData = 
cast(ubyte[])std.file.read("Wallpaper_001.png");


should work. f.name = "Wallpaper_001.png" only says "create a 
file named Wallpaper_001.png inside the zip". It doesn't say 
"put the Wallpaper_001.png file into the zip".


Very good! Work very well. I was trying using rawRead. Now work 
fine.


How add png image to zip file using std.zip?

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

ZipArchive zip = new ZipArchive();
std.file.write("foo.zip", zip.build());

ArchiveMember f = new ArchiveMember();
f.name = "Wallpaper_001.png";

zip.addMember(f);
std.file.write("foo.zip", zip.build());

File is added with file size 0.
How can I use expandedData for add images files? Or what I use 
for it?


Re: How can I check if template variable parameter is iterable before handle it?

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

On Sunday, 21 February 2021 at 12:47:46 UTC, Boris Carvajal wrote:

On Sunday, 21 February 2021 at 11:58:11 UTC, Marcone wrote:

import std;

void foo(T)(T bar){
	static if (bar.isiterable()) // Need Somethin to check if bar 
is iterable.

{
// Execute it if bar is iterable.
foreach (i; bar)
{

}
}
else {
// Execute it if bar is NOT iterable.
}

}

void main(){
foo(1);
foo([1, 2, 3, 4, 5]);
}


https://dlang.org/library/std/traits/is_iterable.html

import std.traits : isIterable;

void foo(T)(T bar){
static if (isIterable!T)
{
...


Thank you.

// Function isiterable()
bool isiterable(T)(T arg) nothrow {try {static if 
(isIterable!T){return true;} else {return false;}} 
catch(Throwable){return false;}}


How can I check if template variable parameter is iterable before handle it?

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

import std;

void foo(T)(T bar){
	static if (bar.isiterable()) // Need Somethin to check if bar is 
iterable.

{
// Execute it if bar is iterable.
foreach (i; bar)
{

}
}
else {
// Execute it if bar is NOT iterable.
}

}

void main(){
foo(1);
foo([1, 2, 3, 4, 5]);
}


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


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]);


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


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-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.


  1   2   3   >