Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
X# examples - Hello world
Message
From
17/10/2019 17:05:48
 
 
To
17/10/2019 12:45:50
General information
Forum:
Visual FoxPro
Category:
VFP Compiler for .NET
Miscellaneous
Thread ID:
01671443
Message ID:
01671541
Views:
106
Likes (1)
Suggest:
FUNCTION Spinner
    STATIC LOCAL i = 0
    STATIC LOCAL ARRAY aRay = {"|", "/", "-", "\"}
    RETURN aRay[i++ % 4]
ENDFUNC
> Some of the extra syntax requirements are not necessary and could be implied. Since "STATIC LOCAL i = 0" contains no decimal points, assume integer.
> If it is "STATIC LOCAL i = 0.00" assume a floating point or double with an assumed 2 decimal points, etc.

Yes that is possible in X#, but slows down the execution speed if not strictly declared. Your solution I can then also say i = "Blah" and only receive a runtime error. In my solution I will get a compile time error with X#. Earlier detection of bad programming.

> LOCAL ARRAY is already an existing syntax in VFP, and use of the { .. } for initializers is very common in languages.

True, however in X# LOCAL a = {"A", "B", "C"} is all that is needed for a lazy array initialization.

> Handling "i++ % 4" will work the same with 0 as it will be 500 million. No need to keep it in the range of 0..3.

I keep it in the range, since I am a purist.

> I note also you're making your arrays reference from 0 instead of 1. While more compatible with other languages,
> it is not compatible with existing VFP / XBASE code. You might want to have some kind of SET ARRAYBASE TO 0 | 1
> setting somewhere, which allows the base to be 1 instead of 0, in which case you should use:

Yes and as I indicated in my comment on the line, the compiler already have a switch /az to force 0 based. The default is 1 based. I just prefer 0 since I interface a lot to c# code and hence makes it easier.
Johan Nel
George, South Africa
Friend of XSharp (FOX) member
E-mail : johan(dot)nel(at)xsinet(dot)co(dot)za
Web site : https://xsharp.info
X# runtime : https://github.com/X-Sharp/XSharpPublic
Radio talk : https://blog.aksel.com/2019/07/why-xsharp-might-be-tool-foxpro.html
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform