BeginPackage["MathExperiment`"]; 
$importData::usage="Global variabel hvor data fra filimport opbevares";
fetchFile::usage="fetchFile henter data fra excel-filer";


Begin["`Private`"];
(*  version 12.0.0, 02.01.2020 *)
SetOptions[InputNotebook[], AutoGeneratedPackage->Automatic];
$importData={};
$dataFileName="";
$fileInfo="Filstørrelse: ";
$fileStatus="Status: ";

fetchFile:=DynamicModule[{},
InitializationValue[$importData,"KernelSession"]={};
Initialize[$importData];

InitializationValue[$dataFileName,"KernelSession"]="";
Initialize[$dataFileName];

Panel[
Grid[{{InputField[Dynamic[If[MemberQ[{"","$Failed"},$dataFileName],"Filnavn: ","Filnavn: "<>$dataFileName]],String,Enabled->False,FieldSize->{60,1}]," ",FileNameSetter[Dynamic[$dataFileName],"Open",{"Excel filer"->{"*.xlsx","*.xls"}},Appearance->"         Vælg datafil        ",BaseStyle->{Bold,FontSize->12}]},
{InputField[Dynamic[If[MemberQ[{"","$Failed"},$dataFileName],$fileInfo,$fileInfo<>ToString[FileSize[$dataFileName]]]],String,Enabled->False,FieldSize->{60,1}]," ",Button["Klik for at hente data",$importData=Import[$dataFileName][[1]],Enabled->Dynamic[¬MemberQ[{"","$Failed"},$dataFileName]],BaseStyle->Dynamic[If[¬MemberQ[{"","$Failed"},$dataFileName],{Bold,FontSize->12},{Italic,FontSize->12,FontColor->GrayLevel[0.95]}]]]},{InputField[Dynamic[If[Length[$importData]==0,$fileStatus,$fileStatus <>" Data er hentet"]],String,Enabled->False,FieldSize->{60,1}]," ",Button["Klik for at se data",Print[$importData//TableForm],Enabled->Dynamic[Length[$importData]>0],BaseStyle->Dynamic[If[Length[$importData]>0,{Bold,FontSize->12},{Italic,FontSize->12,FontColor->GrayLevel[0.95]}]]]}}]
]
];
End[];
EndPackage[];