Alpha DevCon 2018
Results 1 to 15 of 15

Thread: Running a Summary op on Runtime shadow...

  1. #1
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,376

    Default Running a Summary op on Runtime shadow...

    I haven't tested this on a server-client scenario yet (using runtime shadowed), but a couple of questions occurred to me that if a summary operation creates a new table:

    1. Where does it put it - or where SHOULD I put it?
    2. Do I have to add the table to the local machine's adb to use it?
    3. If 2, then that table won't be shadowed so will not exist when optimized

    Color me confused as to how I should write my script for an op that creates a temp table.

    A somewhat related question - does anyone know if tablesum() can be used on a table with only one record? I tried this in a calculation and it worked when there were more records but not with only one.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,954

    Default Re: Running a Summary op on Runtime shadow...

    ? tablesum("dest",".T.","ttl") '1 record
    = 4

    ? tablesum("dest",".T.","ttl") 'no records
    = 0
    There can be only one.

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,954

    Default Re: Running a Summary op on Runtime shadow...

    1. Where does it put it - or where SHOULD I put it? 'available to all users or just the current user? For all it would go in the networked directory, single user, on their machine.
    2. Do I have to add the table to the local machine's adb to use it? 'no, you can reference it with the full path
    3. If 2, then that table won't be shadowed so will not exist when optimized
    There can be only one.

  4. #4
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,376

    Default Re: Running a Summary op on Runtime shadow...

    I know Ray from Capetown has mentioned creating shadow tables on the local desktop. But I am not sure that is what I need to do. My thought is once I have the temp tables created and place them on the server, the shadow optimize should pick them up. Then my scripts ought to be able to point to the local shadowed table to run the summary - IF the summary works that way. Do you think it will? Otherwise I can hard code paths to the server...
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  5. #5
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,376

    Default Re: Running a Summary op on Runtime shadow...

    Quote Originally Posted by Stan Mathews View Post
    ? tablesum("dest",".T.","ttl") '1 record
    = 4

    ? tablesum("dest",".T.","ttl") 'no records
    = 0

    Your 1st example is similar to what I get when there is only 1 record and the amount being totalled is 1 (works only if the table is re-indexed - but then I have timing issues). I decided to summarize the summary table to get the total and that has been more consistent when run from a form. But now I have 4 summary ops to code... instead of my original 2.
    Last edited by MoGrace; 10-16-2017 at 07:36 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,954

    Default Re: Running a Summary op on Runtime shadow...

    If you have or can get a table pointer you could try <TBL>.RECORD_CONTENT_GET(), if not then TABLE.EXTERNAL_RECORD_CONTENT_GET() to get a list of field values into a variable. Then use *TOTAL() on the result. Not sure why tablesum() is giving you problems so just suggesting an alternative.
    There can be only one.

  7. #7
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,376

    Default Re: Running a Summary op on Runtime shadow...

    Thanks, I was looking for an alternative when I came up with the re-summarizing idea. It would probably be easier than what I am doing... Its a process you know, you think you can do something until you find out you can't! I've been in here over 15 years and I still rarely know what I am trying to do.

    I am using a record-list listbox to populate my variable with the summary table. And that won't give me a value to total, only to return on user selection.

    Just to give you an idea of what I am trying to do - which is reproduce a 'spreadsheet':

    signinmon.jpg monsum.jpg
    Last edited by MoGrace; 10-16-2017 at 09:39 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  8. #8
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,463

    Default Re: Running a Summary op on Runtime shadow...

    From docs.

    Code:
    dim this_path as C
    dim bare_path as C
    dim app_path as C
    dim shadowed as L
    dim shadowed_path as C
    
    this_path=:a5.Get_Path()
    
    bare_path=:a5.Get_Master_Path()
    
    if len(alltrim(bare_path)) = 0 then 'if zero, not shadowed
        shadowed =.F.
        app_path = this_path + chr(92)
    else
        shadowed =.T.
        app_path = bare_path + chr(92)
        shadowed_path = this_path + chr(92)
    end if
    You'll want to use this_path to get the shadowed location.

    You can use shadowed_path in your summary code to locate the output file.
    Last edited by Al Buchholz; 10-16-2017 at 11:15 PM.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  9. #9
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,376

    Default Re: Running a Summary op on Runtime shadow...

    Thanks Al,
    What has me curious is whether or not, when running this summary code in a shadowed runtime, I should use the master path to the file or can I use the path to the local shadowed table? Your code will test which AA copy I am using, but which do I need for my script? IOW - Will the local path write a summary operation correctly to a shadowed table? Hopefully, if it will; then getting the current path is all I need.
    Last edited by MoGrace; 10-17-2017 at 01:42 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  10. #10
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,463

    Default Re: Running a Summary op on Runtime shadow...

    1. Is this a multi-user system?

    2. Where do you want the summarized table to be?

    3. What other issues are you considering? What are you going to do with the summarized table after you have generated it?
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  11. #11
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,376

    Default Re: Running a Summary op on Runtime shadow...

    1. Yes, maybe 6 or 7 users.
    2. Server - accessible locally - after initial creation should become shadowed tables on local machines.
    3.a. Why I decided to do this?
    3.b. The table the form is based on is used to create 2 summarized tables. Then these 2 are summarized again into 2 temp tables to get the totals of the count field in the first 2. When the user changes the Month the table is queried, then a button will run the summary script to update the lists in the 2nd Tab. I suppose I could make this a one-step process instead of two; but right now just getting it to work is my goal! And so far on my developer copy - it is.

    I have a runtime shadow on my developer machine, but am not sure that works quite the same way as in a live networked environment - hence the question.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  12. #12
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,376

    Default Re: Running a Summary op on Runtime shadow...

    I decided to try a 3rd summary op using a set. If my script opens the set and gets pointers to the tables - how does that work in scripting a summary op?

    s - set.open_session("sum_race")
    hdr = s.appt
    chld = s.race

    here is what the builder produced:
    Code:
    'This Operation is defined for a set. A set can only be opened in its own session.
    'Therefore, the evaluate_template_private() function is used. It executes code in a new session.
    evaluate_template_private(<<%code%
    'In case the destination table name is stored as a relative file name, or uses an alias
    'in the drive/path specification, use the filename_decode() function to convert the
    'filename to an absolute filename.
    summarize_db_name = filename_decode("[PathAlias.ADB_Path]\test_racesum.DBF")
    
    'Prompt for any ASK variables in filter/order expressions......
    ask_vars = <<%list%
    Askd_Begin_Date
    Askd_Ending_Date
    
    %list%
    prompt_result = a5_prompt_for_ask_vars(ask_vars,session_variables(session_get()))
    if prompt_result <> "OK" then
        end
    end if
    table.reset("sum_race.set")
    tbl = table.current()
    
    ON ERROR GOTO ERROR1512201709220761
    
    
    sum.db = summarize_db_name
    sum.db_dd_delete = .F.
    sum.result_overwrite = .F.
    sum.order = "RACECODE+X"
    sum.filter = "BETWEEN(APPTDATE,VAR->ASKD_BEGIN_DATE,VAR->ASKD_ENDING_DATE)"
    sum.options = "I"
    sum.fields = 5
    sum.field1 = "RACECODE"
    sum.code1 = 0
    sum.field2 = "race->RACE"
    sum.code2 = 6
    sum.field3 = "Racecode"
    sum.code3 = 2
    sum.field4 = "X"
    sum.code4 = 0
    sum.field5 = "\"filter\""
    sum.code5 = 16
    
    tbl.summarize()
    
    
    GOTO CONTINUE1512201709220761
    ERROR1512201709220761:
    ON ERROR GOTO 0
    ui_msg_box("Error","Error running Summarize Operation"+crlf()+error_text_get())
    END
    CONTINUE1512201709220761:
    
    'Add the table just created by the Summarize operation to the Database..
    file_add_to_db(summarize_db_name)
    
    %code%)
    Notice it wants to use evaluate_template_private(), also table.reset() to make it the current table in the session - is this necessary? Shouldn't set.open_session() accomplish this?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  13. #13
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,954

    Default Re: Running a Summary op on Runtime shadow...

    The genies create operations/code without making any assumptions about anything else which might be occurring. The evaluate_template_private() encapsulation - "protects you in case the code you want to run uses a variable with the same name as your calling code and you don't want it to be overwritten." The table.reset() accomplishes similar protection.

    Since you know the particulars of your procedure you can often eliminate the extra precautions which the genie generates.
    There can be only one.

  14. #14
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,376

    Default Re: Running a Summary op on Runtime shadow...

    Good - thanks Stan.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  15. #15
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,954

    Default Re: Running a Summary op on Runtime shadow...

    My favorite is sometimes you will see a line like

    varname = eval(""This is text."",local_variables())

    shortens to

    varname = "This is text."
    There can be only one.

Similar Threads

  1. Runtime Shadow & Full Lic Shadow together?
    By MoGrace in forum Alpha Five Version 10 - Desktop Applications
    Replies: 2
    Last Post: 04-18-2013, 08:57 PM
  2. Running Shadow on Windows 7
    By gagsoft in forum Alpha Five Version 10 - Desktop Applications
    Replies: 2
    Last Post: 09-16-2012, 12:05 PM
  3. Shadow Runtime Install
    By sollasollew in forum Alpha Five Version 9 - Desktop Applications
    Replies: 13
    Last Post: 02-09-2012, 05:40 AM
  4. Runtime Vs Shadow system
    By Kwasi Nkrumah in forum Alpha Five Version 9 - Desktop Applications
    Replies: 2
    Last Post: 11-30-2009, 06:38 AM
  5. settings to runtime shadow
    By martinwcole in forum Alpha Five Version 5
    Replies: 7
    Last Post: 04-17-2004, 12:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •