Ali, please add text above to your book!
Ali, again big thanks for your book, without it I was not able
how to work with D.
But for me now absolutely clear what difference between:
auto theTask = task(someFunction);
and:
auto theTask = task!anOperation();
I have App that read config sections. If the section is true I
want to run it in new thread.
if (parseconfig.obsmpplots_load == true)
{
auto obsmpplots = new ObsmpPlots(db);
auto theTask = task(obsmpplots.getPlots);
Now I am trying to learn how to build GUI apps in D. But I have
some troubles.
http://code.dlang.org/packages/tkd
1. I can't understand how to set window size in example on page
above. I looked at docs and found only how to create new window.
But here I do not see any procedure that create
For my regret I need example to understand how to work with шею
Could you show me at last passing fileToOpen to another instance?
Oh I understood. It's means that it work only of two or more
element's is placed one after one?
The question appear here
http://stackoverflow.com/questions/28546572/how-to-find-duplicates-in-array-of-strings-in-d
I can't understand, why uniq work for array of int but do not
work with array of strings.
int[] arr = [ 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 ];
writeln(uniq(arr));
Iterates unique - _consecutive_ - elements of the given range
Could you explain what does it's mean? I do not understand what
is _consecutive_ mean in this content... and why it's not work
with strings...
I do not use antivirus. It's floated error. I can't reproduce it.
But sometime it's appears again.
Several times I encounter problem when DUB is hanging for a long
time
It's look like that when I tun DUB from folder of current project
it's do not show me nothing, just move cursor on next line for a
long time.
http://img.ctrlv.in/img/15/02/07/54d5c37f6d3c3.png
running dub from any other
ldc supports solaris/x86
but druntime/Phobos support will most likely be lacking what
does it's mean? It is not fully work or what?
My next job will be related with prorgamming under Solaris. I
dont know version but suppose it will be something pretty out of
date.
Once i had seen topic about D and Solaris, but i want to ask if D
solaris version is ready for production or it is alpha? Does
anybody have experience with it?
I need to compare to DateTime. I looked at docs and found opCmp
for DateTime type.
The problem is that I can't understand how to use it.
http://dlang.org/phobos/std_datetime.html#DateTime
opCmp(in DateTime rhs);
what is rhs?
I am trying to do something like this:
if( DateTime.opCmp(dtindb,
+ n.days solved my problem.
Thanks! Could anybody say how can I use roll if I need to date to
date.
For example I need to plus:
DateTime currentdt = cast(DateTime)(Clock.currTime());
with another DateTime var foo.
foreach(f; files))
{
if (canFind(to!string(f), ))
{
writeln(whitespace found:);
writeln(f);
Thread.sleep( dur!(msecs)( 50 ) ); // sleep for 50
milliseconds
}
Just interesting is there any plans to replace net.curl on native
lib? I mean not plans for long future, but some stuff on which
somebody active work?
Try to update dub. There was issue in old version with path with
whitespace.
On Sunday, 25 January 2015 at 22:14:09 UTC, Adam D. Ruppe wrote:
On Sunday, 25 January 2015 at 21:24:06 UTC, Suliman wrote:
I need extract data inside rel (somedata)
string s = element.rel;
Do you mean something like this?
string s = element.rel;
foreach(row;
On Monday, 26 January 2015 at 17:24:23 UTC, Adam D. Ruppe wrote:
On Monday, 26 January 2015 at 17:17:55 UTC, Suliman wrote:
Do you mean something like this?
I just mean to get the value of the rel=something attribute,
use
element.rel;
assert(element.rel == something);
The element is the
But is it good practice to fail with exception during passing
unknown parameters? Maybe std.getopt.config.passThrough should be
as default?
I really can't remember Apps that crush if pass to in unknown
parameters.
Adam, I understood how to select URLs, but how extract values of
attributes from such selection?
a href=/ class=post-tag title=show questions tagged
'javascript' rel=somedata
I need extract data inside rel (somedata)
Look for Passing unrecognized options through in the
documentation.
Oh I see, but first part of question is still actual.
And also what is benefits of using getopt instead of parsing
args[] manually?
First of all it's seems bug in docs:
void main(string[] args)
{
getopt(
args,
length, length,// numeric
file,data, // string
verbose, verbose, // flag
color, color);// enum
...
}
with args inside getopt I am getting:
Ali, you are right it's my error:
getopt(
args,
and I did:
args.getopt
(
args,
Am I right understand that args in args.getopt is UFCS syntax
style?
Adam, please add more simple docs about your parser on site.
Also it would be perfect to create dub, for easier including
parser to project.
void IMGsInsert(string [] fullimgurl)
{
foreach (url; fullimgurl)
{
string sqlinsert = (sqlrequest)
writeln(sqlinsert);
Thanks for detail answer. I stopped at error:
source\cpl_vsi.d(70): Error: module stat is in file
'std\c\stat.d' which cannot
be read
I do not know where I can find this module.
If someone wan't to attempt to create binding, or finish my here
is link of my half-done job
I am trying to understand how to use C++ lib from D.
For my App I need http://www.gdal.org
I had read about using C++ libs from D, and understood that there
is 2 ways:
1. Make binding - convert .H to .d (I still do not fully
understand what is it)
2. Use directly C++ lib (.dll)
I decided to
thanks!
Am I right understand that in next code scope(exit) stmt.close();
occur after this execution? And it will close connection so stmt
in function become unavailable.
this(parseConfig parseconfig)
{
[]
auto conn = ds.getConnection();
I need to construct complex SQL request, like:
string sql = (INSERT INTO test.geomagnetic (`date`,
`a_fredericksburg`, `fredericksburg`, `a_college`, `college`,
`a_planetary`, `planetary`) VALUES ('%s', '%s', '%s', '%s', '%s',
'%s', '%s');, date[i], a_fredericksburg[i], fredericksburg[i],
Please show the _clean_ input, followed by an output example.
Bye,
bearophile
to prevent visual corruption I had past it here:
http://www.everfall.com/paste/id.php?ftzy9lxr6yfy
Just FYI use prepared statements instead of string concatenation
for SQL queries.
You mean some tools, that
std.string.format interpolates string with the same behavior as
writefln
Thanks!
On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote:
Suliman:
void foo()
{
writeln(test);
writeln(mystring);
}
foo();
}
I guess you have to remove that line.
Bye,
bearophile
Why? I can't call function in instance of class?
class Test
{
string mystring;
this(string mystring)
{
this.mystring = mystring;
}
void foo()
{
writeln(test);
writeln(mystring);
}
foo();
}
source\app.d(303): Error: function declaration
Ali, thanks for example, I understood it, but I am still can't
understand how to write code above without passing this as
parameter...
On Sunday, 4 January 2015 at 15:37:53 UTC, Suliman wrote:
Ali, thanks for example, I understood it, but I am still can't
understand how to write code above without passing this as
parameter...
But now I think that possible is mess architecture of app if I
meet such problem...
I think it's fine to have a global config instance.
Alternatively you can pass the config to both the
seismoDownlead and MySqlWhatever classes.
// there ist enforce(cond, msg) for this in
std.exception/std.conv, dunno.
if (!exists(confpath)) throw new Exception(ERROR: config.ini
do not
class parseConfig
{
string dbname;
string dbuser;
string dbpass;
string dbhost;
string dbport;
uint status;
this()
{
auto checkLinkCode(string link) // we need to check all links to
be sure if they are alive
{
return
Thanks! I will try!
D is my first compilable language, I wrote only some scripts
without OO before.
So in my case your suggestion is best practice? Or there is any
more simple way to pass config and data to MySQL class?
Anything declared in main() is local to main and not a global.
Ok! So I need create multiple instances of the parseconfig?
Or please suggest me any solution, I really can't understand how
to be in such situation...
Oh mama mia! I did it!
http://www.everfall.com/paste/id.php?a5pp73ns1e4k
auto seismodownload = new seismoDownload(emsc_csem, this);
then:
auto mysql = new MySQL(parseconfig,eqs);
So could anybody show me better way? As I said I did not fully
understand how use global class instance...
I looked at my code and it's seems that I can create instance of
MySQL in main.
void main()
{
auto parseconfig = new parseConfig();
auto mysql = new MySQL(parseconfig, seismodownload);
}
In parseConfig I am creation instance of seismoDownload:
class parseConfig
{
if
What I am doing wrong?
http://www.everfall.com/paste/id.php?iwh4qdcqv6zi
Well, there's no `parseconfig` there. Do you expect the
`parseconfig` from line 30 or line 193 to be available in line
170?
From line 30.
In line 193 I am get in instance of class instance of parseconfig
to be able
I need to pass some config to ddbc driver. When I use static
const all work ok.
static const string PGSQL_UNITTEST_HOST = localhost;
static const intPGSQL_UNITTEST_PORT = 5432;
static const string PGSQL_UNITTEST_USER = postgres;
static const string PGSQL_UNITTEST_PASSWORD = Infinity8;
But why variant:
static const int PGSQL_UNITTEST_PORT = 5432;
do not require of implicit convert to!short() at connection
string?
Adam, I trying to build simple app:
import std.stdio;
import postgres;
import database;
void main() {
auto db = new PostgreSql(dbname = test2);
foreach(line; db.query(SELECT * FROM customer)) {
writeln(line[0], line[customer_id]);
}
}
and getting next
Could anybody provide any simple examples of usage DerelictPQ. I
do not have experience of C, and I can't understand how to use
this driver.
I need just basics like connect, select and insert.
http://code.dlang.org/packages/derelict-pq
thanks!
I have done next:
string connString = psql -h localhost -p 5432 -U postgres -d
testdb;
package PGconn* conn;
@property bool nonBlocking(){ return PQisnonblocking(conn) == 1;
}
this(parseConfig parseconfig)
{
void connect()
{
On Wednesday, 24 December 2014 at 14:08:53 UTC, Adam D. Ruppe
wrote:
I haven't used the derelict version but I have used the C
library itself and wrapped it briefly in my postgres.d here:
https://github.com/adamdruppe/arsd/blob/master/postgres.d
Thanks! But few questions:
1. how to build it
DerelictPQ is only a binding to libpq. The only difference is
the
DerelictPQ.load method. Just follow the libpq documentation.
http://www.postgresql.org/docs/9.1/static/libpq.html
Actually, Derelict binds to version 9.3, so the proper link
should be
The problem with 31 string.
http://www.everfall.com/paste/id.php?jgsdz7mdbrnm
If I uncomment it, and server response is return 404 code I code
at runtime throw exception with text:
Can't parse config: HTTP request returned status code 404
I thought that checkLinkCode is throw any king
Oh sorry I understood where problem.
There is also a branch named `develop` which at least compiles,
maybe it is usable.
how to add to dub this branch?
On Sunday, 14 December 2014 at 13:33:27 UTC, Suliman wrote:
There is also a branch named `develop` which at least
compiles, maybe it is usable.
how to add to dub this branch?
Compiling using dmd...
Linking...
OPTLINK (R) for Win32 Release 8.00.15
Copyright (C) Digital Mars 1989-2013 All
If I right understand scope is not good for checking if one of
function is fail.
For example:
string dbpass = config.getKey(dbpass);
string dbpass = config.getKey(dbpass);
string dbhost = config.getKey(dbhost);
string dbport = config.getKey(dbport);
if I will try to add scope(failure)
I reread docs and understood that scope not for such case.
Next code is do what I need:
try
{
string dbname = config.getKey(dbname);
string dbpass = config.getKey(dbpass);
string dbhost = config.getKey(dbhost);
string dbport = config.getKey(dbport);
}
catch
On the code.dlang.org I found SQLLite driver
https://github.com/biozic/d2sqlite3
Look like it's not ready for Windows:
pragma(msg, \nWARNING !!!\nDevelopped for POSIX systems
only.\nNot tested on Windows.\n);
I tried to add import to my project and I got next errors:
Yes I used 2.0.65, but after updating compiler the situation did
not resolved...
http://www.everfall.com/paste/id.php?apd0bfs5z4eg
I am trying to start with http://code.dlang.org/packages/dpq2
But I can't understand where I should to get pq.lib and where I
should to place it. In the Program Files I did not find such
file...
string dbname = config.getKey(dbname1);
scope(failure) writeln(look like dbname is missing);
I am using dini and trying to throw exception if value can't be
extract from config. If I am wrap it's in try-сефср block it's
work or. But in this situation scope block do not execute and I
see only
connect() sends a CONNECT request to the server, as defined
by HTTP [1]. This method is only used when you're working with
proxies and the like. What you most likely want, however, is a
GET request. Use get() for that.
So what is the best way to check status server response (400, 404
etc)
Big thanks Ali!
Only the small last question:
why:
string link = dlang.org;
writeln(connect(link));
cause crash:
std.net.curl.CurlException@C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl
.d(779): HTTP request returned status code 400
0x00404263
My guess is that you have to use HTTPS for CONNECT and that you
have to have credentials for it. (?)
Ali
dlang.org should work on HTTP, but not HTTPS.
Also I do not think that when I connect to HTTPS I should have
any credentials. It's mostly like issue with curl...
Could anybody explain why there is opinion that stack is fast and
the heap is slow. All of them are located in the same memory. So
the access time should be equal.
I can't understand why I am getting exception on next code:
void downloadFile()
{
foreach(link; links)
{
try
{
writeln(connect(link));
}
Am I right understand all exception are derived from
assertThrown
http://dlang.org/phobos/std_exception.html
So msg in catch(Exception msg) is from function
assertThrown?
Could you show me example of how to handle type of exception?
Full function look like this:
auto parseConfig()
{
auto config = Ini.Parse(getcwd ~ \\ ~ config.ini);
string txtlinks = getcwd ~ \\ ~ config.getKey(input_links);
if(!exists(txtlinks))
{
writeln(Can't find input file with list of links.);
auto parseConfig()
{
auto lines = File(txtlinks, r).byLine;
return lines;
}
Error: cannot return non-void from void function
I can't understand the reasons of the error;
Can I return auto from function?
I try to compile simple example:
import std.net.curl;
void main()
{
download(ftp.digitalmars.com/sieve.ds,
D:\\Project\\2014\\txt_downloader\\img\\1.foo);
}
but I am getting error:
function app.download (string[] links) is not callableusing
argument types (string, string)
Look like it was missed installation or so. I installed new copy
of dmd and error gone away.
The downloading still do not work. Work only:
get(dlang.org);
ah, that's it! as spec says, D determines function return value
from
the first 'return' statement it seen. in your case this is
`return;`,
so function return type is determined to be `void`.
if you doing `auto` functions, try to arrange your code so the
first
`return` returning the actual
Running .\txtdownloader.exe
std.stream.OpenException@std\stream.d(50): Cannot open or create
file 'D:\Projec
t\2014\txt_downloader\img\1.foo'
0x0041BA59 in void std.stream.File.open(immutable(char)[],
std.stream.FileMode)
0x00404B75 in void
Is there any way to detect where collision was occurred?
Oh! It's work! I forgot to change path on my home PC!
On Thursday, 27 November 2014 at 17:39:10 UTC, Suliman wrote:
Is there any way to detect where collision was occurred?
It's look like collision was with method name.
Sometimes it's path string may do not have tail slash of the path
Compare:
string path = C:\\folder\\name
string path = C:\\folder\\name\\
in case if I need to append file name to path to get full path I
can get error like:
path ~= foo.txt
C:\\folder\\namefoo.txt
instead of
see std.path, it contains alot of useful things.
I looked there, but found only buildNormalizedPath, but it's not
for such situation...
take a second look then. ;-) you'll find `buildPath()` here too.
Not better:
string foo = D:/code/txtDownloader;
writeln(foo);
foo = foo.buildPath;
foo ~= config.txt;
writeln(foo);
Running .\txtdownloader.exe
D:/code/txtDownloader
Could you quote for me part of docs where it's written? I really
can't understand about what you are taking.
thanks! I understood!
This is an issue with your version of dub with a buggy url
encoding method. Download the latest at code.dlang.org
http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/22266/
Is there any way to set separator? For example I want use '/' or
':'?
And could anybody explain me how the cast is work. How to
understand which types to which may be casted?
I can't understand why foreach loop produce every line by line,
while it's fuctional analog print lines on one string:
foreach(f; file.byLine())
{
writeln(f);
}
auto file = File(foo.txt,r);
file
.byLine()
.writeln;
file content:
-
first sring
second string
-
Thanks! But is there any way to do it with std.algorithm?
Can be skipOver used for it?
In dco source code I have found:
void ShowUsage()
{
writeln(
dco build tool ~ strVersion ~
written by FrankLIKE.
Usage:
dco [switches...] files...
for example: dco
or: dco app.d
build for dfl2: dco
}
I do not see here any \n. Why this code is output all one by
line, and not in single
I am playing with dco. And it's look very helpful for tiny
projects.
I can't understand is it's possible to add to dco.ini Jpath?
I am talking about something like:
dflags=-JD:\code\d\App1\source\
but when I am trying to compile code with dco it's can't find
import.
I looked at source code
I understand it.
I expect what concatenation symbol will stay new line in new line
and not append it's to current:
writeln(
first string
second ~
string
);
I expect:
first string
second
string
but not:
first stringsecondstring
I can't understand how to get date in format -MM-dd from
Clock.currTime
auto time = Clock.currTime;
And what next? Could anybody give any examples?
You need to check if remote file exist of server and only after
it download шею
Also add scope or try catch block to your code.
I have got few questions about DFL2.
1: What is dco and in which situation I should prefer it's to dub?
2: Old DFL had easy to use GUI Builder. Does dfl2 have such tool?
You are right, after updating Debian to 7.7 dub was installed
successfully
I did 2 steps from http://d-apt.sourceforge.net/
$ sudo wget
http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list
-O /etc/apt/sources.list.d/d-apt.list
$ sudo apt-get update sudo apt-get -y --allow-unauthenticated
install --reinstall d-apt-keyring sudo apt-get update
And now
root@66898:~# apt-get install multiarch-support
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package multiarch-support is not available, but is referred to by
another packag
e.
This may mean that the package is missing, has been obsoleted, or
is only
If you haven't found the problem yet, please post:
1. what is the architecture of your machine? $ lscpu
2. what is the debian version? $ lsb_release -a
root@66898:~# lscpu
Architecture: x86_64
CPU op-mode(s):32-bit, 64-bit
CPU(s):4
Vendor ID:
dmd a.d b.d
Otherwise you can also use ddmd and let it find the module
dependencies by itself.
Am I right understand that if I will put all needed files at src
folder and name main file App.d dub will add all needed files to
App.d ?
I can't understand how to use UFCS with instance of class:
void main()
{
string name = Suliman;
userName username = new userName(name);
/// How to use UFCS here?
userName.name.sayHello();
///
}
class userName
{
string name;
this(string name)
{
this.name = name;
}
Thanks!
Ali Çehreli, could you add this mention and possible the example
to your book?
301 - 400 of 439 matches
Mail list logo