Hello everyone
Before we get into our session for today, I want to take a moment to talk about the software I use to do all of these lessons, Alpha Software. Everything we do here is currently focused on desktop applications but don’t get fooled, Alpha Software is much more than that.
Alpha Software is a company with their eye on the future. Their latest product, Alpha Anywhere is generating a lot of buzz in the industry. Alpha Anywhere
is the first COMPLETE product to RAPIDLY build and deploy HTML5 business applications for mobile devices and personal computers. Here is an article that Dan Bricklin the CTO of Alpha Software wrote and was featured in InfoWorld.
http://www.infoworld.com/t/application-development/dan-bricklin-javascript-beats-native-code-mobile-226537?page=0,0
If you would like to know more about this great product go to
Now on to our lesson.
First we are going to look at adding a single file to our File Organizer table. When the user clicks the button they are presented with a xDialog box with two choices.
- Add File
- New Document
If the user selects Add File, a form is loaded allowing them to fill in the necessary field information for that file.
if addchoice = "Add File" then
form.load("AddFile_Dialog","popup","","center","middle")
AddFile_Dialog.Activate()
AddFile_Dialog.New_record()
AddFile_Dialog.Show()
form.close()
Notice that along with poping up the form, we start a new record as well.
AddFile_Dialog.New_record()
Since this form is bound to the doc_table the record is automatically added to the form and nothing needs to be done except save and close. If you are entering several records using xBasic then you have work to do.
Adding Batch Records
If our user wants to select several records at once and add them to our File Organizer we need to run some xBasic code to perform the task. Watch this short video about the batch adding of records then we will discuss the code that makes it work.
As you can see in the video adding multiple records to a table using xBasic is fast and easy. All database applications are intended for data storage and getting the data into the table can be done either by manual entry (slow and tedious and open to user errors) or electronically (fast and accurate). Part of the explosion of the mobile device is the ability to photograph a document, convert it to text then add the text to the calling application electronically. Sounds like a job for Alpha Anywhere! Lets look at our code.
.....
else if mySelect = "Add Files to TC File Organizer" then
list2 = Listsource
topparent:text2.Object.width = .1
topparent:text2.show()
dim prmpt_title as c
dim prmpt_prompt as c
dim prmpt_default as c
prmpt_title = "File Type Dialog"
prmpt_prompt = "Enter the File Type Group Name"
prmpt_default = "Word Processing"
DIM SHARED xFT AS C
xFT = ui_get_text(prmpt_title,prmpt_prompt,prmpt_default)
t = table.open("doc_table")
t.batch_begin()
for each sel_file in list2
UpdateList = 4.4 / *count(listSource)
if right(Alltrim(sel_file),1) = "." then
goto continueal
end if
FileMgtSystemS:text1.text = ""
FileMgtSystemS:text1.Refresh()
FileMgtSystemS:text1.text = "Adding to TC File Organizer... "+alltrim(file.filename_parse(sel_file,"NE"))
topparent:text2.Object.width = topparent:text2.Object.width + UpdateList
ui_yield()
FileMgtSystemS:text1.Refresh()
xbasic_wait_for_idle()
t.enter_begin()
t.id = 1
t.filetype = xFT
t.file_name = file.filename_parse(sel_file,"N")
if Occurs(" ",RTrim(sel_file)) >= 1 then
t.filenamens = stritran(RTrim(file.filename_parse(sel_file,"N")), " ", "_")
'file.rename(sel_file, file.filename_parse(sel_file,"DP")+RTrim(t.file_name)+t.f_ext)
else
t.file_name = file.filename_parse(sel_file,"N")
t.filenamens = file.filename_parse(sel_file,"N")
end if
t.file_location = Left(file.filename_parse(sel_file,"DP"),-1)
t.startin = file.filename_parse(sel_file,"DP")
t.f_ext = file.filename_parse(sel_file,"E")
CName = sel_file
t.date_created = filefind.get(CName,FILE_FIND_NORMAL,"C")
t.date_updated = filefind.get(CName,FILE_FIND_NORMAL,"T")
t.f_sizec = bytes_to_mega(Val(filefind.get(CName,FILE_FIND_NORMAL,"L")),2)
t.f_size = Val(filefind.get(CName,FILE_FIND_NORMAL,"L"))
t.enter_end()
continueal:
next
t.batch_end()
t.close()
Listsource = ""
goto xdone
.........
This code is part of the code on the on push event of our Do It button on the File Manager form.
Listsource is the variable that holds the file names selected by the user to add to the File Organizer.
First we pop up a simple dialog box asking for a group name for our data which is assigned to the variable xFT.
Next we open our Doc_Table and set the function batch_begin(). When processing a large number of records this function greatly improves the processing time.
Now we use the for each next function to process our list2 and assign each value to a variable sel_file.
We then process some status bar processing code and then do a tbl.enter_begin.
The final step is to assign values to the table fields and to do this we use the variable xFT, filename_parce() and filefind.get() to extract the values we need for each field from the variable sel_file and the global variable CName respectively. Then we end the enter begin, stop the batch enter and close our table. There you have it.
Deleting Records
Alpha Software offers several methods for deleting records in a table. I prefer the following since it allows me to build my own dialog and better control the user interaction. Here is the code for the Remove File button.
dim Shared delchoice as C
'Create an XDialog dialog box to prompt for parameters.
DIM SHARED del_rec as C
add_new = ""
addchoice = ""
DIM SHARED varC_result as C
ok_button_label = "Con&tinue"
cancel_button_label = "&Cancel"
Delete XdialogStyle
dim XDialogStyle as p
XDialogStyle.AccentColor = "White"
XDialogStyle.Color = "#127+127+127"
varC_result = ui_dlg_box("TakeCharge Delete File Dialog",<<%dlg%
{Windowstyle=Gradient Radial Bottom Right}
;
{region}
{font=Times New Roman,10}{color=Gray-80}
{sp=5}You can Remove the File from the TakeCharge Tracker;
{sp=5}leaving the File on the Computer or You can ;
{sp=5}Remove the file from the Tracker and the Computer.;
{endregion};
{line=1};
{font=Times New Roman,10}{color=Dark Teal}
{sp=10}{region}(del_rec:Remove from Table);
{sp=10}(del_rec:Remove from Computer);
{endregion};
{line=1};
{region}
;
{sp=1}<*27=ok_button_label!CONTINUE> <27=cancel_button_label!CANCEL>;
{font=Times New Roman,10}{color=Gray-80}
{sp=5}Click Continue to perform choice or Cancel to Exit;
{endregion};
%dlg%,<<%code%
if a_dlg_button = "CONTINUE" then
delchoice = del_rec
else if a_dlg_button = "CANCEL" then
delchoice = ""
end if
%code%)
if delchoice = "" then
end
end if
if delchoice = "Remove from Table" then
a_tbl = table.current()
a_tbl.delete_range("recno() = Var->rNbr")
End
else if delchoice = "Remove from Computer"
CName = RTrim(Doc_Manager:file_location.text)+chr(92)+RTrim(Doc_Manager:File_Name.text)+Doc_Manager:f_ext.text
a_tbl = table.current()
a_tbl.delete_range("recno() = Var->rNbr")
end if
First the dialog box presents two choices for the user. If they choose to remove the file from the tracker then option one is run which only removes the file from the tracker. If they choose option 2 then the record is removed from the table then they are presented a final deletion warning about permanently deleting the file. If they select yes the file is remove; cancel and the file is left on the computer.
Well that’s it for today’s session. I hope you found it informative. Thanks again for stopping by and Remember, if you need help with an Alpha Software application or wish to inquire about a custom application for your business go to our website
and inquire or contact
NLawson@cdc-TakeCharge.com
Have a great day.
Leave a comment