aldweb

Close I. aldweb

Close II. PC Freeware

Close III. Palm Freeware

Close IV. Palm Shareware

Close V. iziBasic Palm

Close VI. Palm Knowledge

Close VII. Pocket Computer

Close VIII. miniPortail

Special !



Mobile version of
the aldweb Site

m.aldweb.com


Neither French, nor English?

Try one of these flags then:
[de] [es] [it] [pt]
Search




Weather / Spam / www

Lyon Weather


aldweb against spam


Newsletter
To receive news about this website, consider subscribing to our Newsletter.
Subscribe
Unsubscribe
298 Subscribers
Family's web sites

Webmaster - Infos
Friends News
Visits

   visitors

   visitors online

Poll
What do you think of the new design of the aldweb Site?
 
Great !
Beautiful
Average
So ugly...
Results
forum.gifForum - iziBasic - Topic #1526

Forum - Forum
iziBasic - iziBasic


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257

active  Topic # 1526  ANY way to use COPY command on non-"data"-files?

10/04/2007 @ 17:19
by doeni

Anonymous



Is there ANY way to copy files, that are not of "data" type?

In this case, it's "ThQS".

It's really important :(


Write to doeni   Post an answer  Top

[]   

StartPrevious [ 1 2 3 ] NextEnd

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 11
--------
13/04/2007 @ 18:09
by doeni

Anonymous

visitor
I'm stuck...

I read through the manual, but don't get it how to use those pp applets.
Also, i did not find anything in the samples except the same apis i found before :(

I've uploaded the files here:
http://www.jonasweibel.jo.funpic.de/pqs.zip

(the code with the KILL/COPY commands is only in the very last part, starting at label "_saves:")

The Programm is thought to archive Savegames of the RPG "The Quest", named by archived time.

Thanks again
Write to doeni   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 12
--------
15/04/2007 @ 02:27
by aldweb

Anonymous

visitor
OK, if you are stuck... then here is the solution

Here is what the PP applet looks like:

{
FileApplet.pas
'PP applet' for iziBasic
Version 1.0ß1 - April 14, 2007
by Laurent Duveau
Web Site = http://www.aldweb.com
e-Mail = info@aldweb.com


-----------------------
What is FileApplet.pas?
-----------------------

FileApplet.pas is a fully featured 'PP applet' for iziBasic
which is made to delete and copy any type of file, when the
COPY and KILL statements in iziBasic are provided with
restrictions for security purposes.

This 'PP applet' can be used as is in your iziBasic projects.
Please give a look to the FileApplet.ibas sample program source
code to see an example of how to access it.


--------------------------
How to use FileApplet.pas?
--------------------------

SYNTAX

output$ = CALLPP$(100,input$)
input$ : "NumFunction[1 Char],Parameter1[,Parameter2]"
output$: "1" if success, 0 if failure


FUNCTIONS

Delete one file
Parameters: "1,FileName"

Copy one file to another one
Parameters : "2,SourceFileName,TargetFileName"


-------------------------------
Parametrization and integration
in an iziBasic project
-------------------------------

Step #1: Replace the 'LDFI' CreatorID in the first line of the
source code below to the CreatorID defined in your
iziBasic source code (see CREATORID compiling directive)
Also replace the 'FileDanger' label in the second line
to the name of your application (the part of the iziBasic
source code file name prior to the '.ibas' extension)

Step #2: Compile your iziBasic project

Step #3: Compile this 'PP applet'
}


{$code appl,LDFI,code,100}
program FileDanger;

type
iBasFunType=function(S:string):string;

var
iBasCallPP:iBasFunType;


// -----------------------
// Palm OS API definitions
// -----------------------

{$i PalmAPI.pas}
function DmDeleteRecord(dbP:DmOpenRef;index:UInt16):Err; inline(SYSTRAP,$A057);


// -------------------------
// General purpose functions
// -------------------------

function ExtractStrI(const sMyString:String;index:UInt8):string;
var
sResult:String;
i,j:UInt8;
begin
sResult:='';
j:=1;
for i:=1 to Length(sMyString) do
if sMyString[i]=',' then
j:=j+1
else
if j=index then
sResult:=sResult+sMyString[i];
ExtractStrI:=sResult;
end;


function IntToString(N:integer):string;
var
S:string;
begin
StrIToA(S,N);
IntToString:=S;
end;


// ---------------------------
// RsrcDB management functions
// ---------------------------

function DeleteFile(DBName:String):boolean;
var
dbID:UInt32;
begin
if DBName='' then
DeleteFile:=false
else begin
dbID:=DmFindDatabase(0,DBName);
if dbID=0 then
DeleteFile:=false
else
DeleteFile:=DmDeleteDatabase(0,dbID)=0;
end;
end;


function CopyFile(const DBSource,DBTarget:string):boolean;
const
dmHdrAttrResDB=1;
dmHdrAttrBackup=8;
dmHdrAttrCopyPrevention=64;
DmMaxRecordIndex=-1;
var
IDSource,IDTarget:LocalID;
RefSource,RefTarget:DmOpenRef;
MyResH:Memhandle;
MyResP:MemPtr;
MyResS:UInt32;
h:MemHandle;
p:MemPtr;
NBRecords:Integer;
i,j:UInt16;
dbID:LocalID;
resType:UInt32;
resID:UInt16;
name:String;
attributes,ResAttr:UInt16;
t,c:UInt32;
Erreur:Err;
begin
IDTarget:=DmFindDatabase(0,DBTarget);
if IDTarget>0 then
Erreur:=1 // Target File already exists
else begin
IDSource:=DmFindDatabase(0,DBSource);
if IDSource=0 then
Erreur:=1 // Source File does not exist
else begin
Erreur:=DmDatabaseInfo(0,IDSource,name,attributes,nil,nil,nil,nil,nil,nil,nil,t,c);
if Erreur=0 then begin // Attributes from Source File were read
ResAttr:=attributes and dmHdrAttrResDB; // Is Source File a data or a resource file?
name:=DBTarget;
Erreur:=DmCreateDatabase(0,name,c,t,ResAttr=1);
if Erreur=0 then begin // Target File was created
IDTarget:=DmFindDatabase(0,name);
if IDTarget=0 then
Erreur:=1 // Target File was not found
else begin
attributes:=attributes or dmHdrAttrBackup; // Set backup bit for Target File
Erreur:=DmSetDatabaseInfo(0,IDTarget,nil,attributes,nil,nil,nil,nil,nil,nil,nil,nil,nil);
if Erreur=0 then begin // Everything OK, we can now proceed with the file copy
RefSource:=DmOpenDatabase(0,IDSource,dmModeReadOnly);
if ResAttr=1 then // Resource File to copy
NBRecords:=DmNumResources(RefSource)
else // Data File to copy
NBRecords:=DmNumRecords(RefSource);
if NBRecords>0 then begin // Source File is not empty, there are records to copy
RefTarget:=DmOpenDatabase(0,IDTarget,dmModeReadWrite);
if ResAttr=1 then begin // Resource File copying...
for i:=0 to NBRecords-1 do begin
MyResH:=DmGetResourceIndex(RefSource,i);
MyResS:=MemHandleSize(MyResH);
MyResP:=MemHandleLock(MyResH);
DmResourceInfo(RefSource,i,resType,resID,nil);
h:=DmNewResource(RefTarget,resType,resID,MyResS);
if h<>nil then begin
p:=MemHandleLock(h);
DmSet(p,0,MyResS,0);
DmWrite(p,0,MyResP,MyResS);
MemHandleUnlock(h);
DmReleaseResource(h);
end;
MemHandleUnlock(MyResH);
DmReleaseResource(MyResH);
end;
end
else begin // Data File copying...
for i:=0 to NBRecords-1 do begin
MyResH:=DmGetRecord(RefSource,i);
if MyResH<>nil then begin // Valid record
MyResS:=MemHandleSize(MyResH);
MyResP:=MemHandleLock(MyResH);
j:=i;
h:=DmNewRecord(RefTarget,j,MyResS);
p:=MemHandleLock(h);
DmSet(p,0,MyResS,0);
DmWrite(p,0,MyResP,MyResS);
MemHandleUnlock(h);
DmReleaseRecord(RefTarget,j,false);
MemHandleUnlock(MyResH);
end
else begin // Deleted record, not yet synchronized with HotSync
j:=i;
DmNewRecord(RefTarget,j,1);
DmReleaseRecord(RefTarget,j,false);
DmDeleteRecord(RefTarget,j);
end;
DmReleaseRecord(RefSource,i,false);
end;
end;
end;
DmCloseDatabase(RefTarget);
end;
DmCloseDatabase(RefSource);
end;
end;
end;
end;
end;
CopyFile:=Erreur=0;
end;


// ------------------
// PP applet function
// ------------------

function CallPP(S:string):string;
var
WhatToDo:byte;
ReportDone:boolean;
begin
WhatToDo:=StrAToI(S[1]);
case WhatToDo of
1: ReportDone:=DeleteFile(ExtractStrI(S,2));
2: ReportDone:=CopyFile(ExtractStrI(S,2),ExtractStrI(S,3));
else
ReportDone:=false;
end;
CallPP:=IntToString(Ord(ReportDone));
end;


begin
iBasCallPP:=CallPP;
end.

I hope you realize how the iziBasic KILL and COPY statements are easy and fast to use compared to this applet source code... (that is the whole reason for the iziBasic success story!)

And, here is a sample iziBasic source code to call the PP applet:
' FileDanger.ibas

{CREATORID "LDFI"}
{VERSION "1.0"}
{RESOURCEFILE "FileApplet.rsrc"}

BEGIN
GOSUB _WhatToDo
REPEAT
INPUT K$
SELECT CASE K$
CASE "1"
T$="2,MemoDB,MemoDB~copy"
GOSUB _DoIt
CASE "2"
T$="1,MemoDB~copy"
GOSUB _DoIt
CASE "3"
T$="2,iziBasic,iziBasic~copy"
GOSUB _DoIt
CASE "4"
T$="1,iziBasic~copy"
GOSUB _DoIt
END SELECT
UNTIL K$="5"
END

_WhatToDo:
PRINT "What to do?"
PRINT "1. Copy MemoDB to MemoDB~copy"
PRINT "2. Delete MemoDB~copy"
PRINT "3. Copy iziBasic to iziBasic~copy"
PRINT "4. Delete iziBasic~copy"
PRINT "5. Exit"
RETURN

_DoIt:
P$=CALLPP$(100,T$)
CLS
GOSUB _WhatToDo
PRINT
PRINT ">> ";
PRINT K$;
PRINT " -> ";
IF P$="1" THEN
PRINT "I did it!"
ELSE
PRINT "Something went wrong..."
ENDIF
RETURN


For your convenience, the full package can be downloaded here: izibasic_fileapplet.zip

(and you may use the FileApplet.rsrc resource instead of recompiling the FileApplet.pas file all the time)

Cheers,
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 13
--------
15/04/2007 @ 13:22
by doeni

Anonymous

visitor
Many Thanks again.

Anyhow, when i want to compile the pp code with PP, i get an error in line 173:

"dmsetdatabaseinfo" unknown

When first trying to compile the code, i also got an error in line 76:

"palmAPI.pas" not found

i downloaded the file from the PPCompiler website. Is this the right file?


The only thing i changed on the code is the CreatorID from LDFI to QstL and the app name from Filedanger to Questlist.

Write to doeni   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 14
--------
16/04/2007 @ 00:13
by aldweb

Anonymous

visitor
Hello doeni,

You are very close from success.

I don't know what happens with your PalmAPI.pas. Make sure to get the good version, which in the following ZIP file: PgmPP.zip (to validate you have the right file, the header should be
{ PalmAPI
Version 7 - November 24, 2004
(...)


Cheers,
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 15
--------
16/04/2007 @ 14:36
by doeni

Anonymous

visitor
Thanks again, anyhow, i was using

Version 5 - May 11, 2004

Now everything works fine!

Write to doeni   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 15
--------
16/04/2007 @ 15:45
by doeni

Anonymous

visitor
it seems the database is not a 100% copy:

the records have different ID's:

http://img264.imageshack.us/img264/4769/kopievonimagec2494827rv5.jpg

Anyway to solve that?
otherwise my app will be useless
Write to doeni   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 17
--------
16/04/2007 @ 21:03
by aldweb

Anonymous

visitor
Hello doeni,

Here is what is written in the Palm OS Programmer's Companion manual:
The Unique ID must be unique for each record within a database. It remains the same for a particular record no matter how many times the record is modified. It is used during synchronization with the desktop to track records on the Palm OS device with the same records on the desktop system.

To my understanding, this Unique ID is automatically issued at the time of the DmNewRecord() API call.

Also, if I remember well, Unique IDs are not preserved through the process of backing up and re-installing a database to the Palm.
=> So, when reinstalling any of the 2 files (by HotSync), the original one or the copy, there is a great chance that these IDs would no more be the same for the same record in the 2 files.

This being said, the PP applet could still be updated by adding a DmRecordInfo() API call to retrieve the Unique ID value of the source and a DmSetRecordInfo() API call to update the target accordingly.

Cheers,
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 18
--------
17/04/2007 @ 14:41
by doeni

Anonymous

visitor
The Unique ID's have to be unique for each record within a database.

So for different databases, the record IDs can still be the same (and are the same, as i checked with my 4 original savegames).

I mailed Stewe (who is one of the developers of the game), his answer:

You're right, those IDs are all extremely important.
Maybe you should copy the saved game record by record. And make sure you set the record ID for each.

Normally a pdb record doesn't need ID, as I know (since that's a "database"). Prc records need ID (as a "resource"). The Quest uses its pdbs as prcs.

The Quest creates the records normally, without any tricks. I just need to set the ID.

Stewe


Is this realizable?
Write to doeni   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 19
--------
17/04/2007 @ 21:44
by aldweb

Anonymous

visitor
Hello doeni,

I think that there is a confusion between 2 types of IDs:
1. The one that I explained which is a Unique Seed ID set to each database record for HotSync purposes (not used otherwise, except maybe by applications for weird purposes - this might explain Stewe's sentence: "The Quest uses its pdbs as prcs."), since this ID is not maintained if you had to reinstall the database.
This is the one you highlighted in your printscreen.
And, yes, it is realizable, this one can be forced during the copy, as I explained in my previous post, although I have never heard of someone doing it... but I might be wrong. For instance, if you copy the file with FileZ, is this ID ported to the new file?
Is it really a must? Did you check your application without setting it?

2. The Record ID (which is the on the left side of your printscreen, starting at index 0 and up).
There, having those copied in the right order might have importance, according to the application (this is what Quest's developer wrote, to my understanding).
And, this should be done in the right order by my code.

Cheers,
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 20
--------
18/04/2007 @ 14:45
by doeni

Anonymous

visitor
1.Interesting: I tried to copy the copied file with Filez, but i always got a error message. Copying the original savegame works without any problems.
But i have experimented with the original savegames, and there, the ID (the highlighted one) is ported to the new file.
It did not change, still the same IDs.

My application works without problems. I can copy and delete the files. The only problem is that the Game does not identify/accept the copied file (because of that ID's..), and this is the purpose of my app :(


2.Yes, those Id's are in the same order and have same size.
Write to doeni   Post an answer  Top
StartPrevious [ 1 2 3 ] NextEnd
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
[]
Forum Topic  Forum 



 
^ Top ^