Stealth Client Forum

Альтернативный клиент Ultima Online
Текущее время: 02.07.2020 10:42

Часовой пояс: UTC + 2 часа




Начать новую тему Ответить на тему  [ Сообщений: 7 ] 
Автор Сообщение
 Заголовок сообщения: [SOLVED] "'BEGIN' expected"; How do I use Pascal "Units"?
СообщениеДобавлено: 17.05.2020 1:41 
Не в сети Neophyte
Neophyte

Зарегистрирован: 17.05.2020 0:11
Сообщения: 12
Hello,

I am trying to make Pascal/Delphi "Units" for my scripts to use, but I think I don't understand the workflow in Stealth Client.

These are my questions:
  • How does the compiler find "Unit" scripts when I reference them in the "Uses" statement?
  • How do you troubleshoot Units? How am I supposed to compile or validate Units?

I can only get the compiler to decide if Units are good or bad, but I can't figure out how to make it give me specifics (what's wrong and on what line).

You can stop reading here if you like, but in case it helps, here are the details:

My Stealth Client version is v8.10.2 and I am running it on 64-bit Windows 7.

I wrote a Program script and a Unit like so:
Код:
// Comments
// ...
// Comments
Program SpeedLooter;
Uses
   SpeedLooterLib;
...

Код:
Unit SpeedLooterLib;

interface
...

When I load the SpeedLooter script and try to compile/run it, I get an error like this:
Цитата:
Compiler: [Error] at (21:2): Unit 'SpeedLooterLib' not found or contains errors


I have tried it with SpeedLooterLib.pas in Scripts\, then in Scripts\Uses\, and I get that same result every time.

So I wondered if it was "not found" or if it "contains errors".

I've put it in the places I expect and named it as described in the docs. I try to investigate the "contains errors" possibility next.

I loaded the SpeedLooterLib.pas script as the active script and tried to compile/run it. The compiler gave me this error:
Цитата:
Compiler: [Error] at (1:1): 'BEGIN' expected


To exclude the possibility that I just don't understand Pascal syntax well enough, I try the same thing with the example files that came with Stealth Client in the Scripts\Uses\ folder. I get the same result:
Цитата:
Compiler: [Error] at (1:1): 'BEGIN' expected


That experiment seemed important, so I took a screenshot:
Изображение

If that doesn't work, here's a Google Photos link:
https://photos.app.goo.gl/qTDRzDB6WoFszGpC7

Now if I replace the above SpeedLooter program with this:
Код:
// Comments
// ...
// Comments
Program SpeedLooter;
Uses
   CheckSave;
...


... then the compiler gets past the "Uses" statement.

First, this suggests to me that it is possible to use Units (at all). I wasn't sure up to this point. It also suggests to me that the compiler CAN find files in the Scripts\Uses\ directory. That makes it seem more likely that the compiler IS actually finding the SpeedLooterLib.pas file/Unit when I try to use it.

I'd like better confirmation, hence why I asked, "How does the compiler find "Unit" scripts when I reference them in the "Uses" statement?"

By process of elimination, and assuming the "not found or contains errors" message is accurate, then my SpeedLooterLib unit has errors in it (and CheckSave.pas does not). However, I can't find out what they are.

If I try to compile or run ANY "Unit" file, the compiler will give me the "'BEGIN' expected" error. So this doesn't tell me what's wrong.
If I try to compile or run a "Program" script that "Uses" a unit, then it will give me the "Unit 'BlahBlahBlah' not found or contains errors" error. This tells me that something is wrong, but not what.

In either case, I can't get the compiler to proceed deeper into the SpeedLooterLib file and tell me where my mistakes are. Hence my other question, "How do you troubleshoot Units?"

Thank you!
- Chad


Последний раз редактировалось Chad Joan 20.05.2020 22:26, всего редактировалось 1 раз.

Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: "'BEGIN' expected"; How do I use Pascal Units in Stealth
СообщениеДобавлено: 17.05.2020 12:18 
Не в сети Developer
Developer

Зарегистрирован: 24.03.2005 17:05
Сообщения: 3931
do you have folder Scripts\Uses\ in your Stealth folder? There many examples there.
If not - (re) download stealth from site.

_________________
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: "'BEGIN' expected"; How do I use Pascal Units in Stealth
СообщениеДобавлено: 17.05.2020 19:48 
Не в сети Neophyte
Neophyte

Зарегистрирован: 17.05.2020 0:11
Сообщения: 12
Yes, I have the Scripts\Uses\ in my Stealth folder.

It has two examples in it from when I downloaded Stealth:
Scripts\Uses\checksave.pas
Scripts\Uses\hungry.pas

Whenever I try to "run" either of them, I get the "Compiler: [Error] at (1:1): 'BEGIN' expected" error. I need to have some way to "run" scripts in the Scripts\Uses\ folder so that I can debug them and find my syntax errors.


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: "'BEGIN' expected"; How do I use Pascal Units in Stealth
СообщениеДобавлено: 19.05.2020 20:16 
Не в сети Developer
Developer

Зарегистрирован: 24.03.2005 17:05
Сообщения: 3931
you should not run the, directly.

In your script write

uses checksave;

and after this you can call procedure CheckSave from this unit.

_________________
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: "'BEGIN' expected"; How do I use Pascal Units in Stealth
СообщениеДобавлено: 20.05.2020 22:23 
Не в сети Neophyte
Neophyte

Зарегистрирован: 17.05.2020 0:11
Сообщения: 12
I was wondering about that. Good to know!

But when I let the main script just pull in the module, I instead get the "Unit '____' not found or contains errors" error from the calling module/program. It always points at the beginning of the module (Unit), so I still have no way to debug the Unit.

However, I think I've found some things that solve my problem.

Here's what I was looking at:
Изображение

Here's what I probably should be looking at:
Изображение

In that latter picture ("System Journal" at bottom of main GUI), I can see that this particular error in the module ("Uses") file prints as "Identifier expected" and is on line 6 at column 22. Great!

Before that, I had also found this "Uses" path configuration setting that might contribute to the "not found" facet of the error:
Изображение

I haven't played with these things much yet, but hopefully this will keep working.

I think there is an opportunity here to improve Stealth: have the EditScript "error log" display more than just one line from the compiler/interpreter. That would save us from having to flip back-and-forth when a module (Unit) fails (or when any other information is missing from the EditScript window). More importantly, I think this would help other people and new users avoid a pitfall (I'm fine now that I have a workaround).

It would be even more stellar if the go-to-error feature would take me to the line in the module script rather than the "Uses" line in the main script.

Do you have a bug tracker or something like a github repository? I'd write a short feature request if I could :)

Thank you for keeping in touch and for working with me on this!


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: [SOLVED] "'BEGIN' expected"; How do I use Pascal "Units"
СообщениеДобавлено: 26.05.2020 6:29 
Не в сети Developer
Developer

Зарегистрирован: 24.03.2005 17:05
Сообщения: 3931
>>Do you have a bug tracker or something like a github repository? I'd write a short feature request if I could :)

no

about EditScript error list - will check it

_________________
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: [SOLVED] "'BEGIN' expected"; How do I use Pascal "Units"
СообщениеДобавлено: 26.05.2020 9:12 
Не в сети Neophyte
Neophyte

Зарегистрирован: 17.05.2020 0:11
Сообщения: 12
Wow, thank you! :D


Вернуться к началу
 Профиль  
Ответить с цитатой  
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 7 ] 

Часовой пояс: UTC + 2 часа


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  


Тюнинг и аксессуары. Тюнинг внедорожников: магазин 4х4 в Одессе. Интернет магазин "AMAX".
Также, на правах рекламы: школьный сайт: school-work.net и еще один: https://www.youtube.com/channel/UCFSPHKHjP22tEl8Rjcst9Fw.


Рейтинг@Mail.ru
Powered by phpBB® Forum Software © phpBB Group