[NTLK] FilePad and Excel import/export

From: Jaime Méndez (servafin_at_prodigy.net.mx)
Date: Wed Oct 20 2004 - 20:25:36 PDT


Hi FieldPad Users,

Here are two usefull Dash Board scripts.
Did you ever have cvs or xls data in your PC that you would have wanted to
export as a data base into your Newton?
Did you ever wanted to export FilePad dataBase to your PC in an excel
workSheet?

You can do it with Quick Figure Pro, QFig exch, DashBoard and this two
scripts:

QFig Pro to FilePad:
*start the dashBoard script from your workSheet Data.
*Data has to be in colum "A" and start in cell "A1".
*FilePad cabinet and entries need to be created first.
*This script does not creat cabinets nor its entries, it only changes the
entry values to a specified field within specified delimeters.

local i:=0;
local j:=0;
local k:=0;
local b:=0;
local b1:=0;
base:=:DashBoardDoDialog('string,"Cabinet?","Export to
FilePad",nil,"Cancel","Continue");
if base = nil then return;
mySoup := getUnionSoupAlways(base&".frm");
myCur:=mySoup:query({indexPath:'_uniqueID});
myCur:Reset();
n:=myCur:CountEntries();
myEntry:=myCur:Entry();
if not isSoupEntry(myEntry) then
   begin
      modalConfirm(base&&"doesn't exist!",["X"]);
      return;
   end;
name:=:DashBoardDoDialog('string,"Entry?", "Export to FilePad"
,nil,"Cancel","Continue");
if name = nil then return;
refi:=:DashBoardDoDialog('string,"Begin key?

*any entry data in your cabinet as an index reference to start whith",
"Export to FilePad" ,nil,"No key","Use key");
reff:=:DashBoardDoDialog('string,"End key?

*any entry data in your cabinet as an index reference to end whith", "Export
to FilePad" ,nil,"No key","Use key");
repeat
   if k=n then
      begin
         modalConfirm(name&&"doesn't exist!",["X"]);
         return;
      end;
   regname:= myEntry.FieldName;
   reg:= myEntry.FieldNumber;
   myCur:Next();
   myEntry:=myCur:Entry();
   k:=k+1;
until strEqual(regname,name);
mySoup := getUnionSoupAlways(base);
myCur:=mySoup:query({indexPath:'_uniqueID});
myCur:Reset();
n:=myCur:CountEntries();
myEntry:=myCur:Entry();
ddxFrom:=getRoot().|qfig:donv|;
repeat
   j:=j+1;
   if refi <> nil then
      foreach item, value in myEntry do
         if strEqual(value&"",refi) then b:=1;
   if refi = nil then b:=1;
   if reff <> nil then
      foreach item, value in myEntry do
         if strEqual(value&"",reff) then b1:=1;
   if b = 1 then
      begin
         i:=i+1;
         foreach item, value in myEntry do
            if strEqual(item&"",reg) then field:=item;
         ddxFrom:selectRange("a"&numberstr(i)&":"&"a"&numberstr(i));
         celda:=ddxFrom:getCurrCell();
         celda:= intern(celda[0]);
         myEntry.(field):=numberStr(ddxFrom:getValue(celda));
         EntryChangeXmit(myEntry,nil);
      end;
   myCur:Next();
   myEntry:=myCur:Entry();
until b1 = 1 or j = n;
if b = 0 then
   begin
      modalConfirm(refi&&"doesn't exist!",["X"]);
      return;
   end;

FilePad to QFig Pro:

local i:=0;
local j:=0;
local k:=0;
local b:=0;
local b1:=0;
if Not visible(getRoot().|qfig:donv|) then
   getRoot().|qfig:donv|:open();
base:=:DashBoardDoDialog('string,"Cabinet?","Export to QFig
Pro",nil,"Cancel","Continue");
if base = nil then return;
mySoup := getUnionSoupAlways(base&".frm");
myCur:=mySoup:query({indexPath:'_uniqueID});
myCur:Reset();
n:=myCur:CountEntries();
myEntry:=myCur:Entry();
if not isSoupEntry(myEntry) then
   begin
      modalConfirm(base&&"doesn't exist!",["X"]);
      return;
   end;
name:=:DashBoardDoDialog('string,"Entry?", "Export to QFig Pro"
,nil,"Cancel","Continue");
if name = nil then return;
refi:=:DashBoardDoDialog('string,"Begin key?

*any entry data in your cabinet as an index reference to start whith",
"Export to QFig Pro" ,nil,"No key","Use key");
reff:=:DashBoardDoDialog('string,"End key?

*any entry data in your cabinet as an index reference to end whith", "Export
to QFig Pro" ,nil,"No key","Use key");
repeat
   if k=n then
      begin
         modalConfirm(name&&"doesn't exist!",["X"]);
         return;
      end;
   regname:= myEntry.FieldName;
   reg:= myEntry.FieldNumber;
   myCur:Next();
   myEntry:=myCur:Entry();
   k:=k+1;
until strEqual(regname,name);
mySoup := getUnionSoupAlways(base);
myCur:=mySoup:query({indexPath:'_uniqueID});
myCur:Reset();
n:=myCur:CountEntries();
myEntry:=myCur:Entry();
getRoot().|qfig:donv|:newSheetScript(nil,nil);
ddxFrom:=getRoot().|qfig:donv|;
repeat
   j:=j+1;
   foreach item, value in myEntry do
      if strEqual(item&"",reg) then campo:=value;
   if refi <> nil then
      foreach item, value in myEntry do
         if strEqual(value&"",refi) then b:=1;
   if refi = nil then b:=1;
   if reff <> nil then
      foreach item, value in myEntry do
         if strEqual(value&"",reff) then b1:=1;
   if b = 1 then
      if Not strEqual(campo,"") then
         begin
            i:=i+1;
            ddxFrom:selectRange("a"&numberstr(i)&":"&"a"&numberstr(i));
            celda:=ddxFrom:getCurrCell();
            celda:= intern(celda[0]);
            ddxFrom:parseEntry(campo,celda);
         end;
   myCur:Next();
   myEntry:=myCur:Entry();
until b1 = 1 or j = n;
if b = 0 then
   begin
      getRoot().|qfig:donv|:close();
      modalConfirm(refi&&"doesn't exist!",["X"]);
      return;
   end;
ddxFrom:addCell(campo,celda);
ddxFrom:selectRange("a1:a"&numberstr(i));

-- 
This is the NewtonTalk list - http://www.newtontalk.net/ for all inquiries
Official Newton FAQ: http://www.chuma.org/newton/faq/
WikiWikiNewt for all kinds of articles: http://tools.unna.org/wikiwikinewt/


This archive was generated by hypermail 2.1.5 : Wed Oct 20 2004 - 22:00:02 PDT