Вниз  MobPascal
- 18.07.2014 / 11:08
Fantastik
  Пользователь

Fantastik 
Сейчас: Offline
Не подскажете как, я в этом полный ноль:-D
- 18.07.2014 / 11:54
skyezeno
  Пользователь

skyezeno 
Сейчас: Offline
fantastik, to use library download any library eg. Lib_base64v2,
then move the library to the folder where you are saving your source code(*.mpas) e.g e:/mobpas/
each library has it own functions..
Then in your code before "begin" add

uses mylib;

where mylib is the name of your library as in Lib_mylib.class.
Then in your code to use the function of a library you write the library_name.function() as in mylib.myfunction()
e.g I want to use Lib_base64v2.class

program libtest;
uses base64v2;
begin
$en = base64v2.encodestring('HelloWORLD');
drawText($en, 5, 5);
repaint;
delay(5000);
end.

But note that many midletpascal library are not yet compatible with mobpascal and they will generate exception.
More info below...

[url]annimon.com/forum/index.php?act=post&id=339232[/url]

Изменено skyezeno (18.07 / 11:57) (всего 2 раза)
- 18.07.2014 / 12:29
Fantastik
  Пользователь

Fantastik 
Сейчас: Offline
skyezeno, thanks
- 18.07.2014 / 13:16
skyezeno
  Пользователь

skyezeno 
Сейчас: Offline
fantastik, did you speak russian or you are using translator...
- 18.07.2014 / 15:18
Fantastik
  Пользователь

Fantastik 
Сейчас: Offline
skyezeno, I speak in Russian.
- 19.07.2014 / 18:39
Fantastik
  Пользователь

Fantastik 
Сейчас: Offline
byte:=readByte(res);
if byte=EOF then break;
text:=text+chr(byte);

выдает ошибку , переменная или фунция EOF не найдена, че делать, помогите плз
- 19.07.2014 / 19:03
ВитаминКО
  Супермодератор

ВитаминКО 
Сейчас: Offline
Fantastik, а что это за библиотека? допустим, это jsr75. тогда пробуй if byte= jsr75.EOF then break;
__________________
 わからない!!
- 19.07.2014 / 19:52
skyezeno
  Пользователь

skyezeno 
Сейчас: Offline
fantastik, to me this is an error in mobpascal, 'EOF' is recognised as a string in the compiler and 'byte' is an integer.
But anyway what you do is first put you code in a 'while-loop' e.g

while (resourceAvailable(myresource)) do
begin
//code
end;

where "myresource" is your resource variable.

then write the "EOF" as "stringtointeger('EOF');"

so your final code will look like

program testing;
var
res: resource;
byte: integer;
text: string;
begin
res:=openResource('/myresource.txt');
while (resourceAvailable(res)) do
begin
byte:=readByte(res);
if (byte=stringtointeger('EOF')) then
begin
closeResource(res);
break;
end;
text:=text+chr(byte);
end;
// remaining codes
end.

Note: I have not yet tested the code.
- 19.07.2014 / 19:59
Fantastik
  Пользователь

Fantastik 
Сейчас: Offline
ВитаминКО, Это не либа.
- 19.07.2014 / 20:02
skyezeno
  Пользователь

skyezeno 
Сейчас: Offline
If that method did not work, try this

At the end of your resource e.g "myresource.txt", in a newline add "//resource-end-here//"

then write this code

program testing;
res: resource;
byte: integer;
reader: string;
text: string;
begin
res: openResource('/myresource.txt');
while (resourceAvailable(res)) do
begin
reader := readLine(res);
byte:=readByte(res);
if (reader = '//resource-end-here//') then
begin
closeResource(res);
break;
end;
text:=text+chr(byte);
end;
// rest of your code..
end.

Goodluck..

Изменено skyezeno (19.07 / 20:04) (всего 2 раза)
Наверх  Всего сообщений: 1221
Фильтровать сообщения
Поиск по теме
Файлы топика (98)