![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Remembering Add_ Topic Summary: Created On: 12-Jul-2006 22:43 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Got a wierd need and believe I can resolve it via the "addr_" perm. Somehow.
I need to write generic library functions that will allow Main scripts to either save their dialog settings for later use, or to restore the settings from a previous run. I figure to store the info in a file. I think the following is possible. Write function that lets Main define a globable variable as being saveable; this variable being associated with a particular DBE. void fDefineSaveableVar(string NameOfVariable, Variable) The main would call this function once for every such global variable to be saved. That function, I figure, would not store the value of the varaible in something like a global Skip list, but would instead store the Name and its address. When desiring to save the variables, the Main would call a generic function "fSaveAllVariables" that would read the above Skip list and store the variable names and their current values (at the time this function is called) to a file. When desiring to restore the variables from a previous run, the main would call a generic function "fRestoreAllVariables" that would read the file, then browse the Skip list for the corresonding variable names, then use the address in the skip to restore the value from the file. I'd thus need a way to convert the addresses in the Skip into variables that can be modified. That not possible in the Amish Programmers world, but I'm pretty sure its possible in the wiz-bang Geek Programmers world. - Louie |
|
![]() |
|
![]() |
|
I never knew that tyou could use pointers in DXL in a similar fashion to good old C.
The following is my stab at what you are after, arrived at by trial and error mostly... ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
More fiddlings with string pointers.
There is also an example of using pointers to do buffer subrange stuff without using the string table in DOORSHOME\lib\dxl\standard\import\ileaf\common.inc, but I warn you it ain't pretty... ------------------------- Tony Goodman http://www.smartdxl.com Edited: 13-Jul-2006 at 12:05 by Tony Goodman |
|
![]() |
|
![]() |
|
Forgive Ignorance; what's with the stars: "*pt = *ps"?
|
|
![]() |
|
![]() |
|
The first one is working great. I tried to expand to the ability to save bool (and later int and real) variables, but it failed with exception violations.
|
|
![]() |
|
![]() |
|
Here's the DXL again, this time I have duplicated lines for each type, so you can see where you have to be careful casting the type.
I think that you may need to store the type of the variable in the file so you know how to cast it when reading it back, otherwise you need separate save and restore functions for each type. The stars in my previous post are C syntax for pointers, int x = 0 // declare an integer variable int *px = &x // declare a pointer to an integer and initialise it to point to x *px = *py // set the value pointed to by px to the value pointed to by py (i.e same as x = y) ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
Thanks a great deal there mate. Works real well now.
I wrote separate overloaded Define functions for each variable, each function putting its variable in its own Skip list (skpString, skpInt etc.). This relieves the need to type the value when reading, I just look for the value read in any of the various Skips. I Expanded the scope where the DBE assiciated with the variable is also saved (in its own Skip), figuring the library restore function can automatically update the dialog as well. My real purpose here, btw, is to provide a mechanism to segment long-running scripts such that the Memory leak issue is overcome. If we evaluate all the modules in a project it may take hours as the computer starts to thrash. I figure we could stop after one hour and save the partial results, then close the dialog (to reset the memory leak problem). When the user restarts the dialog, functions know there is such a 'chain' of segments in progress and offer to continue it. Remembering the exact settings from the previous segment and then restoring them is critical to insure the 'chained' script behaves the same from beginning to end. This notion is a lot more grandiose then I first anticipated it, but I need a simple interface for Main scripts to activate or deactive it. - Louie |
|
![]() |
|
![]() |
|
Some scripts have more than one main apply function. I don't suppose you know how to put a function parameter into a Skip list, retrieve it, and invoke that function?
|
|
![]() |
|
![]() |
|
Never done that, but the wizard funtions use function addresses stored in skips so that the correct callback can be assigned according to current page number.
Take a look at the add_wizard_page function in lib\dxl\wizard\common\wizard.inc. ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
Using Goodman's suggestions I've created a script that saves variable values to a file, which can later be retrieved to set the global variables as well as update the DBEs associated with those global variables. The script creates a DBE where the values can be saved, DBEs modified, restored, and printed. The key feature is that the Main script declares which variables and their associated DBEs are to be remembered, the saving and restoring doesn't use those variable names but rather loops throught the saved skips and updates the saved variables addresses instead.
I intend to write a set of Library calls that provide long-running Main scripts the ability to break up the chore into segments, where after one is finished the user can restart the script and it will know to pick-up where the previous segment left off, and dialog options should be the same for all segments of the Chain. I'm hopefull this will prevent the memory-leak thrashing I experience in many of my report scripts. The main technical issue is the storing of variable addresses in a global skip list and later retrieving the addresses and then updating the variable. Don't laugh at the fxxReadWord and fxxReadTABLine functions; these were written many years ago in DOORS v4 and I've never updated them. The other "fChainxxx" functions I intend to make permanant library calls. I've never dealt with indirect addressing since I left school and still don't understand how it works, but I have made it work. I notice I've figured out how to store Function addresses and invoke them later. This way only works because all the called function have a single parameter of type DB; I don't know how to handle functions with differing parameters. Anyway, thanks to Goodman and there you go. - Louie |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Remembering Add_
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.