Page 1 of 2
How to find explanation
Posted: Sat Sep 23, 2017 1:47 pm
by Horst
Hi
I was looking in this forum for a replacement of the ErrorBlock Method and i found this code and i try to understand
TRY
// app execution here
CATCH e AS Exception
LOCAL cMessage AS STRING
cMessage := e:Message
DO WHILE e:InnerException != NULL_OBJECT
e := e:InnerException
cMessage += CRLF+e:Message
ENDDO
ErrorBox{NIL, cMessage}:Show()
END TRY
Here e will be defined as Exception , my problem is - where can i find the explanation of Exception or other Functions/Classes witch has no VO names?
do i have to look into the C# help ?
and if i found the same name, is it the same ?
Horst
How to find explanation
Posted: Sat Sep 23, 2017 2:38 pm
by wriedmann
Hi Horst,
The exception class comes from the .NET framework, best to use Google search and add C# to your search terms.
Wolfgang
How to find explanation
Posted: Sat Sep 23, 2017 4:44 pm
by Chris
Hi Horst,
Yes all the system classes are the same in x#, c# and any other .Net language, and they can be used in exactly the same way, that's one of the beauties of .Net. And in most aspects (apart from VO/xBase in general features and compatibility ), x# can be used in a very similar way to x#.
Chris
How to find explanation
Posted: Sat Sep 23, 2017 8:29 pm
by Phil Hepburn
Hi Chris,
Nice to know that even you mixes up X# and C# from time to time.
Been there and got the tee-shirt ;-0)
Hope you are well and feeling good.
Cheers,
Phil.
How to find explanation
Posted: Sat Sep 23, 2017 8:42 pm
by Chris
Hi Phil,
I use c# only when I need to do some testing with it
Or during the vulcan days, where the base rdd and ntx drivers (and a very small part of the base runtime) were written in c#. But personally I completely avoid using c# if I can.
Been doing well, thanks, hope you're doing fine also! Sorry, didn't get the t-shirt thing!
Chris
How to find explanation
Posted: Sun Sep 24, 2017 8:17 am
by Frank Maraite
Hi Horst,
I use search terms like 'msdn exception'. This leads to
https://msdn.microsoft.com/de-de/librar ... .110).aspx
Above 'Exception Klasse' you will find the link to the complete class library.
https://msdn.microsoft.com/de-de/librar ... .110).aspx
Both links lead to the german version.
It's the power of these .NET libraries that makes X# so powerful.
Frank
How to find explanation
Posted: Sun Sep 24, 2017 3:58 pm
by Horst
Hi to all
Thanks for your words.
Frank said this make the .Net world powerfull. But for a beginner ist realy hard. i Show you a example, i found it in the MS help, there i found this Code.
https://msdn.microsoft.com/de-de/librar ... -snippet-2
int loop1;
NameValueCollection coll;
//Load Form variables into NameValueCollection variable.
coll=Request.Form;
// Get names of all forms into a string array.
String[] arr1 = coll.AllKeys;
for (loop1 = 0; loop1 < arr1.Length; loop1++)
{
Response.Write("Form: " + arr1[loop1] + "<br>");
}
So, here i see: coll == Request.Form
But i cant see why they use the codeword ALLKEYS. what is Coll now ? a Array, a String . if ist a Array ist a multidim Array or a single one ? and why they dont use it directly in the Loop ?
You see, maybe .Net ist powerfull but when you have to many posibilities and no good help/describtion behind its not realy a good thing because you cant find the things you relay need.
i think, this HTTP Class of MS is also using the Basic function like GetEnv () etc .
So i will write my HTTP handling in clear X# / VO Code. And with the VO SDK Classes and Ivo Wessel Juno Class it will not be a hard thing to do that. (mostly works already)
and i hope, the X# Team does not Forget to make a good help
Horst
How to find explanation
Posted: Sun Sep 24, 2017 4:31 pm
by Frank Maraite
Hi Horst,
above the example you find the type of form:
Type: System.Collections.Specialized.NameValueCollection
Follow the link. Now you are at
https://msdn.microsoft.com/de-de/librar ... .110).aspx
There you find, under Eigenschaften:
AllKeys : Gets all the keys in the NameValueCollection.
Follow the link on AllKeys. Now you are at
https://msdn.microsoft.com/de-de/librar ... .110).aspx
Here you read
Type: System.String[]
saying AllKeys is a .NET STRING array.
You see
String[] arr1 = coll.AllKeys;
in the example saying exactly the same.
You're right: at the beginning it's hard. But it's worth the time you spend on. Most scenarios can be done by a few lines of code once you understood the power of collections for example.
Tip: I would open all the links in new tabs. This way you can easy go forth and back. I know, sometimes you will have more than a dozen tabs open.
Good luck
Frank
How to find explanation
Posted: Mon Sep 25, 2017 4:01 am
by wriedmann
Hi Horst,
the power of X# is the possibility to use different programminfg styles:
- you can use it like C# with only the .NET framework, but with xBase syntax.
- you can use it like VO with the VO runtime libraries and the VO functions
- you can mix both styles
Since you know VO, and your applications are written in VO, for sure you will adapt the VO style, but since the .NET framework contains a lot of functionality you are dreaming of in VO, earlier or later you will need to use functionalities from the .NET framework.
Other than the VO datatypes, there are a lot of new ones.
Please look particularly at the Collections. Collections are a sort of arrays, but since .NET does not know dynamic arrays like VO (you cannot add members to a .NET array), Collections take their place.
Please look here:
http://www.c-sharpcorner.com/UploadFile/736bf5/collection-in-C-Sharp/
and here
https://www.tutorialspoint.com/csharp/csharp_collections.htm
Regarding the documentation: the X# team can never document the .NET framework, but you will find much more documentation and much, much more samples you had ever in your VO programming. X# can use a syntax that is near to C#, and if you can read a bit of C#, you will solve nearly every problem.
Personally, I'm using more and more X# modules in my VO applications, because I cannot move them over yet, but I need functionalities from the .NET framework.
There is a lot to learn, and for sure sometimes you will get frustrated, but at the end you will have a lot of fun.
Wolfgang
How to find explanation
Posted: Mon Sep 25, 2017 2:45 pm
by Chris
Hi Horst,
To answer your question about what AllKeys returns, here's from the help:
https://msdn.microsoft.com/de-de/librar ... .110).aspx
So the AllKeys property returns a (single dimension) array of strings (string[]), which contains only the keys from the collection. And the code stores this array that results from AllKeys in an intermediate local variable (arr1), because every time this property is called, this array is generated again. So in order to make sure that this is called only once, the code uses the intermediate variable, it's just for performance reasons.
About documenting the .Net classes, as the guys said, we cannot do that, the size of the .Net framework is incredibly immense, I'm sure it has taken dozens or hundreds of people at MS to document it. And indeed, some times the documentation is not good enough, but after a few weeks that you will be used to it, it will seem a lot easier. We've all been through this process in the past.
Chris