trchandra
10th September 2004, 03:31
Ever since I started working for baan, I always wanted to have history of run program (ttdsk2080m000) commands so that I can easily select instead of remembering and typing everytime. When I was working for Baan Company, I put a enhancement request to the tools department but it did not happen all these years. One of my friends told me that it is available from Reger 5.2 series onwards. I think this feature is already available on latest worktops.
While I was browsing through UI Objects, I thought why I can't create a similar session like ttdsk2080m000 to run any standard session with provision to run a command from history. I used create.object() function to create a dropdown listbox with command history. I thought this program may be useful for developers and super users who use 'Run Program' more often. Here is the list of screen shot and if anyone is interested I can post the code as well.
~Vamsi
10th September 2004, 07:14
By definition of this forum - all posts have to have code attached. You may be able to optimize your code by using a tools function that does listboxes, instead of using create.object.
Please post the code with the appropriate license.
trchandra
10th September 2004, 18:09
|******************************************************************************
|* Title : Run Program Proxy
|* Author : Ravi Tiruvaipati
|* Date : 09/09/2004
|******************************************************************************
|* Script Type : 4GL
|* Description :
|* License :
|* Copyright 2004 by Ravi Tiruvaipati
|*
|* All Rights Reserved
|*
|* Permission to use, copy, modify, and distribute this software and its
|* documentation for any purpose and without fee is hereby granted,
|* provided that the above copyright notice appear in all copies and that
|* both that copyright notice and this permission notice appear in
|* supporting documentation.
|*
|* Ravi Tiruvaipati and Baanboard.com DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|* AND FITNESS, IN NO EVENT SHALL Ravi Tiruvaipati nor Baanboard.com BE LIABLE FOR ANY
|* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|* OR PERFORMANCE OF THIS SOFTWARE.
|******************************************************************************
|****************************** DECLARATION SECTION ***************************
declaration:
table tttadv111
table tttaad121
extern domain tcmcs.str30 prog.name
string history(30,30)
string err.mess(80)
string pacc(20)
long isObject
domain ttadv.cpac cpac
domain ttadv.vers vers
domain ttadv.rele rele
domain ttadv.cust cust
domain ttadv.cmod cmod
domain ttadv.cprs cprs
long depth
long listbox
long ret
long fp
string history.file(80)
string command(30)
string list.items(4096)
string temp.items(4096)
long list.length
long sel.item
long strlen
long placeholders(900)
long nohistory
#pragma used dll ottdllvrcsearch
|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
form.1:
init.form:
history.file = bse.tmp.dir$() & "/" & logname$ & ".history"
create.history.list()
|****************************** CHOICE SECTION ***************************
choice.cont.process:
on.choice:
if not nohistory and get.object(listbox,DsNselectedId,sel.item) and
sel.item > 0 then
prog.name = strip$(history(1,sel.item))
endif
run.the.process()
|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************
functions:
function void run.the.process(){
pacc = curr.pacc$
if prog.name(1;1) = "o" then
isObject = true
cpac = prog.name(2;2)
cmod = prog.name(4;3)
cprs = strip$(prog.name(7))
else
isObject = false
cpac = prog.name(1;2)
cmod = prog.name(3;3)
cprs = strip$(prog.name(6))
endif
select ttaad121.*
from ttaad121
where ttaad121._index1 = {:pacc, :cpac}
and ttaad121._compnr = 0
as set with 1 rows
selectdo
endselect
vers = ttaad121.vers
rele = ttaad121.rele
cust = ttaad121.cust
select ttadv111.*
from ttadv111
where ttadv111._index1 = {:cpac,:vers,:rele,:cust}
and ttadv111._compnr = 0
as set with 1 rows
selectdo
if isObject then
depth = vrc_search_object(cpac, |to get right VRC for object lookup
cmod,
cprs,
ttadv111.tdep,
ttadv111.tver,
ttadv111.trel,
ttadv111.tcus)
else
depth = vrc_search_session(
cpac,
cmod,
cprs,
ttadv111.tdep,
ttadv111.tver,
ttadv111.trel,
ttadv111.tcus)
endif
endselect
if prog.name = "ttaad4500" or
prog.name = "ttaad4100" then
activate(prog.name)
add.to.history()
kill(pid)
else
if depth > 0 then
activate(prog.name)
add.to.history()
end()
else
message(prog.name & " not found!")
endif
endif
}
function add.to.history(){
long fp1
string temp.file(80)
string temp(80)
temp = strip$(prog.name)
if component.exists.in.history(temp) then
return
endif
temp.file = creat.tmp.file$(bse.tmp.dir$())
fp1 = seq.open(temp.file,"w")
seq.puts(prog.name,fp1)
seq.flush(fp1)
fp = seq.open(history.file,"r")
while not seq.gets(command,30,fp)
seq.puts(command,fp1)
endwhile
seq.close(fp)
seq.flush(fp1)
seq.close(fp1)
ret = file.cp(temp.file,history.file)
ret = file.rm(temp.file)
}
function long component.exists.in.history(string comp(80)){
long i
string temp1(80)
for i = 1 to list.length
temp1 = strip$(history(1,i))
if comp = temp1 then
return(true)
endif
endfor
return(false)
}
function create.history.list(){
long gwin
long rowcol
long index
long done
long _pos
long index1
long obj.label
|125
fp = seq.open(history.file,"r")
if (fp < 0) then
nohistory = true
return
endif
nohistory = false
gwin = create.object(DsCgwindow, current.mwindow(),
DsNbackground, rgb(192, 192, 192),
DsNx, 0,
DsNy, 30,
DsNwidth, 250,
DsNheight, 40)
rowcol = create.object(DsCrowColumn, gwin,
DsNvspace, 10,
DsNhspace, 18,
DsNnumColumns,2,
DsNfixedDimension, DSHORIZONTAL )
obj.label = create.object(DsClabel, rowcol,
DsNstring, "Select from History " )
index = 0
list.items = ""
done = false
while not done
ret = seq.gets(command,30,fp)
index = index+1
if(index > 30 or ret < 0) then
done = true
seq.close(fp)
else
history(1,index) = strip$(command)
list.items = list.items & strip$(command) & "-" & str$(index) & "-"
endif
endwhile
list.length = index
|list.items = list.items(1;len(list.items)-1)
strlen = len(list.items)
done = false
_pos = 0
index = 0
while not done
_pos = _pos + 1
if _pos < len(list.items) then
if list.items(_pos;1) = "-" then
index = index + 1
placeholders(index) = _pos
endif
else
done = true
endif
endwhile
for index1 = 1 to index
store.byte(0,list.items(placeholders(index1)))
endfor
| message(list.items)
| message(str$(len(list.items)))
listbox = create.object(DsCdDListBox, rowcol,
DsNminWidth, 50,
DsNminWindowSize, 1,
DsNmaxWindowSize, 100,
DsNx, 10,
DsNy, 45,
DsNstringArray, list.items, strlen,
DsNselectedId, sel.item)
update.object(gwin)
}
skoka123
15th October 2004, 08:13
Hi Ravi,
Nice utility.
In case you are wondering, I am Srikanth Koka (Baan, Hyd)??? You can reach me at skoka123@yahoo.com
en@frrom
21st December 2004, 17:15
Hello Ravi,
Interesting utility!! How do I get it running? What session do I create? What form? Only one field "prog.name" on the form?
Thanks in advance,
En
trchandra
21st December 2004, 19:24
Hi En,
All you have to do is create a simple 4GL session with a form and keep a field called prog.name on the form. Copy the attached program script as script for the session and you should be ready to run the session!
regards
en@frrom
22nd December 2004, 10:40
Hey Ravi,
I tried this, but get an error when starting the session: ttstps0168. This error does not even exist in our version -> Baan 5.0B.
Any idea why?
Thanks!!
En.
en@frrom
22nd December 2004, 11:42
False alarm, the error occured because I declared the session/form as without main table, yet the script accidently was type 1,2,3 -> with main table.
I quickly ran the session. The session works only for non Tools sessions (and ttaad4100/ttaad4500). I made the necessary adjustments to get it running also for Tools sessions.
If anyone is interested, I can post the adjusted code.
Regards,
En.
veyant
6th August 2005, 14:30
Hi,
while testing this new run program utility, i am facing followingf error " Table doesn't exist (eror506) can't continue in ttdllvrcsreach.
it fails while executing following code
depth = vrc_search_session
thanks
Sandy
Viplov
6th August 2005, 15:08
Nice utility. Can reduce time for opening sessions
NPRao
6th August 2005, 22:24
while testing this new run program utility, i am facing followingf error " Table doesn't exist (eror506) can't continue in ttdllvrcsreach.
it fails while executing following code
depth = vrc_search_session
This is solved by switching to company 000 and switching back to the original company before/after the function calls - vrc_search_object(), vrc_search_session().
add few more statements -
long curr.comp
curr.comp = get.compnr()
e = switch.to.company(000)
depth = vrc_search_session() or vrc_search_object()
....
e = switch.to.company(curr.comp)
This is a very good utility for BW interface. The Run Program History is provided in Worktop and also short cuts to the sessions or table records.
En,
Please post the changes for others benefit.
There is a alternative function set.enum.array.for.field() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_enumerates_set_enum_array_for_field) for create.object(DsCdDListBox...)
manojsharma
9th August 2005, 07:44
Hi trchandra,
Will it work for BaaN - IV. It is giving error dsnminwindowsize & dsnstringarray not declarated
trchandra
9th August 2005, 18:51
Hi Manoj,
I guess it may not work on Baan IV because of the GUI framework. You may have to modify those create.object() functions and parameters to suit Baan IV environment. I will port this program on Baan IV and let u know if it works.
Regards
dstegink
17th November 2005, 21:15
FYI - Worktop provides this capability in a dropdown list.