PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → C Sharp help
C Sharp help
Started by mimmo, Apr., 12 2023 10:32 AM - 6 replies
Posted on April, 12 2023 - 10:32 AM
Hi all,

I have a problem with C sharp. Windev in the manual says he can use C sharp. The example given is for my 10 year old nephew but from that example it is not clear how to use it at all, we need a better example and more detailed explanations. But my question is not about that.
I took c sharp code of a project which when compiled with visual studio creates a working exe. The same source code you copy into windev and from sometimes incomprehensible compilation errors, then it's not true that you can use c# in windev the implementation has problems.
Is there anyone who has had experience with C# within widnev and can give me some advice?
Thank you

Mimmo
Posted on April, 21 2023 - 7:52 AM
If you have a project in Windev you can write Windev procedures using c# using the Windev editor. Same as with C++ and Python. There are some rules you have to follow. You can't expect to just import c# code and have Windev compile it. The purpose is to allow you to use a programming language you are more familiar with rather than W Language. There is an example project using c# in the "external languages\c#" directory under the Windev directory.
Posted on April, 21 2023 - 8:23 AM
Windev does not compile code designed for other programming environments. You can replace W Language code with C# (or C++ or Python) code in a Windev element procedure. However, it has to use Windev functions rather than Visual Studio windowing functions., for example
Posted on April, 28 2023 - 3:06 PM
Ok let's take for granted the fact that it doesn't compile so what's the point of flaunting that other languages can be used. If possible, give clear instructions, not that half page. Or you can not use it to remove it from the characteristics. A known working program already in use by the customer for some months without problems. I was asked to interface a bluethooth device. I found a developer's c# code on github I posted it but you call the procedure nothing happens. Then out of curiosity I try again a series of functions with .Net and it gives me a series of errors. It no longer recognizes objects. Removed the procedure in C # everything works. So is C# working? I wrote to the free assistance but they told me that I have to pay for that type of assistance. Absurd
Mimmo Ghiara
Registered member
47 messages
Posted on June, 03 2023 - 4:05 PM
Hello,

I think it's better to developp an assembly with Visual Studio.
Then you can import it in Windev.

Sorry, written C# in Windev is not a very good pratice.

--
La complexité d'une solution doit être adaptée à la complexité du problème qu'elle essaye de résoudre.
Registered member
945 messages
Popularité : +102 (110 votes)
Posted on January, 25 2024 - 6:36 PM
indev allows you to write in C# directly in the Windev editor but there are rules to respect.
1° never mix procedures written in WLanguage and C# (You can have several procedure collections)
2° never put a comment before the name of the function.
3° to simplify the code declare a procedure which does nothing in which you will put all the "using"
Example :
usingPhil;
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO.Ports;
using System.Globalization;
//using System.Net;
using System.Net.Sockets;

PUBLIC static void JustForUsing() {
// The "using" declarations located before the prototypes of the C# procedures are taken into account for the entire collection.
// So you might as well put them all once in a procedure that does nothing...
}



Windev uses the compiler located in the directory: C:\Windows\Microsoft.NET\Framework\<framework version>\csc.exe
to generate <project name.dll>
In case of compilation error look at the <project directory> directory.
We find there:
- a file for the global procedure collection containing the C# code: <name of the global procedure collection>.cs
- the Compile.bat file containing the order to create project name>.dll
Note: If compiled correctly, the <project directory>\.NET directory is deleted
To avoid its deletion, create a small error like ".lengt" instead of ".length"

In case of good compilation copy the dll <project name>.dll located in the executable directory
in the directory d:\Program Files (x86)\PC SOFT\WINDEV 24\Programs\FrameWork\Win64x86

You can put the C# code in a .cs file and add it to your project in "Others"
Example :
namespace Phil
{
PUBLIC static class Crc64
{
PUBLIC static ulong compute_crc(string DataString, ulong crc = 0) {

ulong[] TableCrc = {
0x0000000000000000, 0x7ad870c830358979,
0xf5b0e190606b12f2, 0x8f689158505e9b8b,
0xc038e5739841b68f, 0xbae095bba8743ff6,
0x358804e3f82aa47d, 0x4f50742bc81f2d04,
.......................................
};

for (int i = 0; i < DataString.Length; i++){
crc = TableCrc[(byte)(crc ^ (ulong) DataString[i])] ^ (crc >> 8);
}
RETURN crc;
}
}
}


and make the call with the GetCRC64 function
PUBLIC static ulong GetCRC64(string DataString, ulong InitCrc)
{
RETURN Crc64.compute_crc(DataString, InitCrc);
}
Registered member
76 messages
Posted on February, 15 2024 - 12:33 PM
Very informative answer.

WinDev is good, if used correctly.

Thank you.

--
Ben Dell
Riebens Computers Pty Ltd
Southern Africa PcSoft Distributor
www.windevsa.co.za
PcSoft Sales, Support and Training