Public Vars Problem

  • Hello,


    I'm making Lotus script files by translating my omsi script files.

    I'd declared "elec_busbar_main" and "elec_busbar_main_sw" in the {Public Vars} part of main script file.

    This Variables must have used at 3 or more .pas files, so I think It have to be declared at {Public Vars} section.

    Code
    1. {PUBLIC_VARS                            * other Variables are hidden
    2. Elec_busbar_main: boolean;
    3. elec_busbar_main_sw: single;
    4. }


    And this is my Elec.pas script. (I also included this file by using {$I Elec.pas} code.)

    I used variable which already declared at {Public Vars} but It it not worked at importing script and error message "Unknown Identifier "elec_busbar_main"" has occurred.

    When I delete the "doesn't work" parts, It was imported successfully. I just do not know why the variables in One files are taking different result.


    I think I used variables properly (compare to example scripts), but error was occurred. So I wonder if my script is wrong, or there is other method to use Variables that I didn't know.


    Maybe It is basic problem to you, Experts. But I spend more than 24 hours to fix this and did not succeed, So I ask your advice.


    Thank you.

  • It should work, if you put the elec_busbar_main_sw = 1 in brackets like here:

  • Although Variobahn's hint is probably right, there is a BIG missunderstanding with heavy consequences!


    In contrast to OMSI, you have two possibilities of declaring a public variable:

    • declaring it in the {PUBLIC_VARS...} section like you did
    • declaring it "as usual" in Pascal scripts.

    If you just need the variables in more than just one *.pas file, you still can declare it ("outside" of any procedure/function) with the construct

    Code
    1. var
    2. counter: integer;
    3. text: string;

    You just have to declare it above any procedure/function and any {$I xxx.pas}-statement (!), where you will need it.


    The only reason you have to declare a variable in the PUBLIC_VARS section is to use it "in LOTUS", e.g. for animations, lights, materials, particle systems, in the script test window for debugging, plugins...

    • declaring it "as usual" in Pascal scripts.

    Maybe I have to follow this, But I have to use that VAR also at {Public Vars} to test scripts and sounds... I have to find another method.

    Thanks for your apply.

  • Newly created posts will remain inaccessible for others until approved by a moderator.

    The last reply was more than 60 days ago, this thread is most likely obsolete. It is recommended to create a new thread instead.

    The maximum number of attachments: 5
    Maximum File Size: 500 kB
    Allowed extensions: bmp, cfg, ini, jpeg, jpg, lct, ldl, llg, lob, log, lpmtl, lptmt, ltx, pas, pdf, png, railtrack, rar, txt, veh, wav