Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

Variable declarations. 27 Sep 2019 13:45 #10890

  • alanbourke
  • alanbourke's Avatar
  • Topic Author



It looks like all variables have to be declared, for example:
for x = 1 to 10
    ? x
next

... is fine in VFP as there's no static typing. In X# VFP the closest you can get would be this, right?
for var x = 1 to 10
    ? x
next

Please Log in or Create an account to join the conversation.

Variable declarations. 27 Sep 2019 15:02 #10895

  • lumberjack
  • lumberjack's Avatar


  • Posts: 721
  • Hi Alan,

    alanbourke wrote: It looks like all variables have to be declared, for example:

    for x = 1 to 10
        ? x
    next
    ... is fine in VFP as there's no static typing. In X# VFP the closest you can get would be this, right?
    for var x = 1 to 10
        ? x
    next

    Or you can just use a typical XBase style declaration:
    local x
    For x = 1 to 10
      ? x
    endfor
    // Alternatively
    For Local x = 1 AS Int to 10
    ______________________
    Johan Nel
    Boshof, South Africa

    Please Log in or Create an account to join the conversation.

    Last edit: by lumberjack.

    Variable declarations. 27 Sep 2019 16:52 #10899

    • robert
    • robert's Avatar


  • Posts: 3602
  • Alan,
    If you enable 'Memvar' support and enable 'Undeclared memvar' support then this should work without any declarations, but I would not recommend that. It will produce code that is much less efficient
    The least that you should do is declare them locally.
    But it is much better to either declare the type yourself or use the VAR syntax and let the compiler determine the type.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1