Jump to content
TroisVerites

How can I make module script ?

Recommended Posts

Hi All

 

I am working in C++.NET, Python. And at least 20 years that I have more touched a line of pascal. I am a little lost in this world. Advice?

 

I would like to separate the code in multiple files or modules.

 

Consider SeaFight:

 

I would like to have a module for:

-client area-> Client.scar

-Minimap-> MiniMap.scar

-The Map-> Map.scar

-MainMod-> MainMod.scar

 

1) How to compile modules without error ' Unexpected end of file"?

2) How to include modules in the main module 'MainMod.scar'?

2.1) What manners to create modules?

 

3) Can you give me advice on Scar, undocumented functions, a fairly complete tutorial on pascal?

 

Thank you in advance

Link to comment
Share on other sites

1. Usually when you get an unexpected end of file, well There is a few issues that could cause this but the most common is that you are not running your MAIN loop correctly.

 

When you enter Scar and amke your procedures and functions these are ABOVE you main "Begin and End" This last end will have a . on it like this END. the others would have end; to end the function or procedure.

 

Nothing executes unless it is by itself Begin and End which is not inside of a procedure or function.

 

Sorry pretty crappy explaination but I dont have time to write a whole section. You can also view freddy's scar manual and tutorials on Wiki.scar-divi.com I think it is.

 

 

So in your Main script put this at the top of your list for includes

 

[scar]

{$I YOURFolder/Client.scar}

{$I YOURFolder/MiniMap.scar}

{$I YOURFolder/Map.scar}

{$I YOURFolder/MainMod.scar}[/scar]

 

 

If the files are not in a seperate folder and in the same folder as your main script is you can delete the YOURFolder path and just put the .scar

 

 

 

2.1) In your "mod" files as you like to call them you dont need a Main Begin and End loop, dont need a "program new" or any crap like that. Just store your procedures and functions there and you can call them up easy as pie... YourProcedure; would call up the Procedure YourProcedure; which is in your other file.

 

 

As for your 3rd question: Google

Link to comment
Share on other sites

Hi

 

I just would like to know if it is possible to compile a separed file with some procedures . Because when I compile this kind of file , I have always "' Unexpected end of file"?.

 

If I compile a script with a Begin ...end. , it is always fine.

 

Thanks for your reply

Link to comment
Share on other sites

Here is a visual example.

MiniMap.Scar File

[scar]

{-------------------------------------------------------------------------------

MiniMap Functions/Procedure

-------------------------------------------------------------------------------}

Procedure FindME;

begin

end;

//What ever else you want to add

[/scar]

Main Script

[scar]

Program SeaFight;

{$I YourFolder\MiniMap.Scar} // This is a folder in the same Folder/Location of this script the contains MiniMap.Scar

 

begin

FindME;// Do some procedure from minimap.scar...

end.

[/scar]

Link to comment
Share on other sites

HI shadowrecon,

 

Yes , I have understood , what you said.

 

In your sample MiniMap.scar , is there a way to compile this file , without de MainScript and without Error ?

 

Yes I Know I can add a Begin...end. at the end of the file to compile it. But I try to find another clean solution.

 

Thanks

Link to comment
Share on other sites

HI shadowrecon,

 

Yes , I have understood , what you said.

 

In your sample MiniMap.scar , is there a way to compile this file , without de MainScript and without Error ?

 

Yes I Know I can add a Begin...end. at the end of the file to compile it. But I try to find another clean solution.

 

Thanks

 

Umm only other way i would see would to include it in a separate file like you would your main script and run that. I wouldn't recommend just putting it in your main script as errors in there may make you think there is an error in your include. The best way is to just add a begin and end. which i think is pretty easy/simple, while reducing the chances of external errors giving you the run around. =P

Edited by shadowrecon
Link to comment
Share on other sites

HI shadowrecon,

 

Yes , I have understood , what you said.

 

In your sample MiniMap.scar , is there a way to compile this file , without de MainScript and without Error ?

 

Yes I Know I can add a Begin...end. at the end of the file to compile it. But I try to find another clean solution.

 

Thanks

 

What do you mean by compile? It's an include file, it will only compile when included in a script.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...