Alpha Video Training
Page 2 of 2 FirstFirst 12
Results 31 to 53 of 53

Thread: $10,000 Question ~ "The foo variable"

  1. #31
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Quote Originally Posted by csda1 View Post
    for each thingy in vp_Form
    There is no thingy in vp_Form. vp_Form is a pointer. It must be an array, text or collection
    What's throwing me off is the "collection" definition as it applies to X-basic.....
    Years past I worked with code in either VB, or maybe Access.... I remember doing this very thing to display lists of field names. (which were considered a collection)

    My mind keeps thinking there must be a way....


    ~in this instance, to create a simple function that loops through all the field objects in a form and individually sets the enabled properties to either .T. or .F.
    Last edited by SNusa; 02-13-2012 at 09:43 AM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

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

    Default Re: $10,000 Question ~ "The foo variable"

    This will toggle the enabled flag.

    Code:
    dim vp_Form as P = parentform.this
    lst = vp_form.CHILD_ENUM("f=field") 
    for each thingy in lst 
    eval(thingy.value+".object.enabled") =  (.not. eval(thingy.value+".object.enabled"))
    Next

  3. #33
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Got it... Thank you!

    PS: I had somehow missed Stan's post (#29)
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  4. #34
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: $10,000 Question ~ "The foo variable"

    Hi Stan,

    Quote Originally Posted by Stan Mathews View Post
    This will toggle the enabled flag.

    Code:
    dim vp_Form as P = parentform.this
    lst = vp_form.CHILD_ENUM("f=field") 
    for each thingy in lst 
    eval(thingy.value+".object.enabled") =  (.not. eval(thingy.value+".object.enabled"))
    Next
    I'm not sure you can use that format, .value() is not a method of a piece of text which is what thingy is, but I don't have time to actually test it. Below is basically the code that should (haven't looked at the validity of the other methods and properties)

    Code:
    dim vp_Form as P = parentform.this
    lst = vp_form.CHILD_ENUM("f=field") 
    for each thingy in lst 
    eval(thingy+".object.enabled") =  (.not. eval(thingy+".object.enabled"))
    Next
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  5. #35
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: $10,000 Question ~ "The foo variable"

    Ira,

    I did test it. Errors without .value.

  6. #36
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Quote Originally Posted by csda1 View Post
    [B].........There is no thingy.value, thingy.object.name, or any thing else, unless thingy is a pointer, which it won't be for a list. (it might be for a collection or array value, but that would be an array or collection of other objects, who only use methods and properties of those objects)
    Quote Originally Posted by Stan Mathews View Post
    Ira,

    I did test it. Errors without .value.
    Looks like there is a "thingy.value after all!"

    I guess now we have to see what happens in the IW with a call to ?thingy.this..... The For Each "thingy" construct must be one of those special cases? ~ Only a "rookie" (like me) could /would uncover "unexpected results" like this?!?!

    Irrespective, this looks like one of those strange anomalies. (Kind of like when you have to convert a pre-coded action script to inline X-basic ~ to use the .text property instead of the .value property so it works properly)......... I do understand the concepts as presented though.
    Last edited by SNusa; 02-11-2012 at 12:34 AM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  7. #37
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: $10,000 Question ~ "The foo variable"

    One of the good things about the message board is you get notification when someone replies.
    One of the bad things about the messages board: is you keep getting these notification, even when you thought the thread is over!. So, I kept getting these notifications and lately they refer to "thingy".
    I hate "thingies". So I had to investigate, which took me back to your post #28 in which in your code you have:


    Quote Originally Posted by SNusa View Post
    When placed on a on_Push button event (on a form):

    Code:
    dim vc_String as C = ""
    dim vp_Form as P = parentform.this
    
    for each thingy in vp_Form 'vp_Form.Fields_Enum()
    	ui_msg_box("This thingy value:",this.object.name) 'thingy.object.name
    	vc_String = vc_String + this.object.name
    Next
    ui_msg_box("ALL FORM OBJECTS:",vc_String)
    The debugger errors with: Variable "thingy" not found (on first loop).
    Also, this.object.name always refers to the "calling button" name. (understandable, since the for...each loop isn't working)

    I've also tried substituting (see blue remarks) to no avail.....
    (Then I get the "unexpectd expression type in FOR EACH Type is '\' Expression is 'Invoice.Fields_Enum()' error)

    Must be something simple I'm not doing properly here...... ~ Let me guess, the form objects are not part of a "collection" either?
    (Even so, shouldn't the substitutions work? ~ "So close, yet so far".....)
    1-For a starter, you are trying to point to the form using parentform.this and you think that you are, but you are not. You are pointing to the button on the form that you are clicking not to the form itself and it went downhill from there.
    Evidently you "have issues" with "This". Will deal with that later.
    2"-For each" processes a list. There is no list generated by clicking the button, there is no thingy because "thingy" or any other name would subsitute for each item in a list..there is no list..and therefore there are no items..and hence and thus there is no thingy.
    3-When you soak this in, will tackle "This".
    4-Now you got "issues" with ".value" . There is no bugs nor any thingy here either. Will tackle ".value" later. One issue at a time.
    Last edited by G Gabriel; 02-11-2012 at 11:05 AM.

  8. #38
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Hi Stan;

    I actually think I've got it all down now. My last post was in response to post #34, and post #35 regarding the code that actually accomplishes what I was trying to do..... My usage of "thingy" was merely metaphoric. (I don't like "thingy" either. It was just the placeholder I used in the for each constructs to "testing my knowledge" that almost any name/placeholder could be used in the For Each.....

    The additional confusion is a result of the following unexpected contradictions between what should work, and what does work:


    ~Ira had indicated that "thingy" (in this instance) did not have properties and that Stan's code should not work when coded using thingy.value..... Stan's response (to this) was that the code only worked with thingy.value, and Ira's code didn't work without it.....


    Quote Originally Posted by G Gabriel View Post
    One of the good things about the message board is you get notification when someone replies.
    One of the bad things about the messages board: is you keep getting these notification, even when you thought the thread is over!. So, I kept getting these notifications and lately they refer to "thingy".
    I hate "thingies". So I had to investigate, which took me back to your post #28 in which in your code you have:

    1-For a starter, you are trying to point to the form using parentform.this and you think that you are, but you are not. You are pointing to the button on the form that you are clicking not to the form itself and it went downhill from there.
    Evidently you "have issues" with "This". Will deal with that later. ~ GOT IT. I KNOW.

    2"-For each" processes a list. There is no list generated by clicking the button, there is no thingy because "thingy" or any other name would subsitute for each item in a list..there is no list..and therefore there are no items..and hence and thus there is no thingy. ~ GOT IT.

    3-When you soak this in, will tackle "This". ~ I GET IT.


    I know that in this instance (within the "loop" here), "this" refers to the button itself. (And using vp_Object=this.this could/would create a pointer reference to the button... ~So using vp_Object.hide() would then hide the button on the form.) ~ "this" either makes reference to an object (as used here in "loop"), or can return a pointer to an object. Used together it does both. (this.this)


    4-Now you got "issues" with ".value" . There is no bugs nor any thingy here either. Will tackle ".value" later. One issue at a time.

    I think that everyone now will have issues related to using/not using .value appended to thingy. (thingy.value) ~Because without this, (according to Stan) failing to include it, results in the code not working..... According to the two of them: "What's right doesn't work, and what works isn't right in this instance".....
    The remaining question here is: When used in the For Each construct, what type of a5 object is this ("thingy"? (No pun intended.) It behaves like an object with properties..... It has properties that shouldn't exist, according to CSDA.) If this "thingy" is implicitly created as a variable of type C, it stands to reason that you wouldn't need to use "thingy.value" to get it's value. (but apparently you do.)

    PS: This entire thread would appear more "intellectual" had I simply used "result_list" in place of "thingy." ~But the question remains: What type of object is "result_list", since it is "implicitly designated" by a5 within the For Each construct???
    Last edited by SNusa; 02-11-2012 at 02:27 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  9. #39
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: $10,000 Question ~ "The foo variable"

    Andrew

  10. #40
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: $10,000 Question ~ "The foo variable"

    Hi Robert et al,

    It turns out it's a little more complicated as to what happens. FOR EACH Placeholder IN List is an Alpha processing command, and as such is not "normal" XBasic code. The placeholder is returned as a pointer as seen with typeof(), and in fact has a .value property, although you can not enumerate any of the pointer's properties or methods. However, if the placeholder is used in a function parameter, it's value is used for the parameter, not the pointer.

    This is very similar to passing a pointer using Active X from XBasic, and suspect is what is happening.

    If you place the code below as a button's event on a form, you will see 3 different ways that the same value is being returned illustrating this point. Note that this is for a character list, and may be different for an array or collection which I have not had time to investigate.

    As to why I have not really seen it before, for the most part I have not used for each, as it was added in Alpha Five V6, and thus not backward compatible to A5v5 (which I support for some functions). In addition, it is seldom faster than just using a for ... next for most code I create, so there is not much point.

    As for parentform.this. it returns a pointer to the form that the current object (such as a button) is on, no matter how many levels you are into objects (such as browses, tabs etc), so your usage was entirely correct.

    Code:
    dim vp_form as p
    vp_form=parentform.this
    dim list as c
    list=vp_form.fields_enum()
    dim item1 as c
    dim item2 as c
    dim item3 as c
    dim tmpn as n
    
    for each item in list
    	item1=item.value
    	item2=substr(item,1)
    	item3=substr(item.value,1)
    	tmpn=ui_msg_box("Item values","item1="+item1+crlf()+"item2="+item2+crlf()+"item3="+item3+crlf(),UI_OK_CANCEL)
    	IF tmpn=2
    		end
    	end if
    next
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  11. #41
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Quote Originally Posted by aschone View Post
    Good call aschone!!!! I just tried this...... Turns out, my "thingy" is an object pointer after all, created from the field list. ~ Created by .CHILD_ENUM().... A pointer to values in a list (apparently considered a "collection" by Alpha, originally created from field objects. (Talk about going in circles)....

    IRA & STAN: You might want to read this (or maybe not).....

    ~If field objects were a collection (like I think they would have/should have been), I never would have asked the questions, which lead to more questions, and a much deeper understanding of all of this........

    Code:
    dim vp_Form as P = parentform.this
    lst = vp_form.CHILD_ENUM("f=field")
    debug(1)
    for each thingy in lst 
    eval(thingy.value+".object.enabled") =  (.not. eval(thingy.value+".object.enabled"))
    eval(thingy +".object.enabled") =  (.not. eval(thingy +".object.enabled"))
    Next
    Both ways work.....
    Using the code above, the net result is no change since the first line sets the object property, and the second line immediately sets it back. (If you rem one out, the other still works fine. Both lines of code working in parallel cancel one another out in this instance.)

    AND... When you debug, and set two (2) watch variables "thingy" and "thingy.value" "the results" get a bit strange....

    thingy.value returns one of the form objects' names (each time through the "loop." (between the {})
    thingy returns {} (nothing) .......Until you click on the expand "+" (plus). Then thingy shows the same thing as thingy.value. (above)
    ~ along with the .value property indicator!

    BUT... Contrary to what Stan experienced, both lines of code works just fine for me.
    (He probably got the error because he was building a list from the returned object values.)
    ~This still makes no sense, because of how both lines of code (blue and green) still work in the code snippet above (attached to a form button on the on_push event)..........


    Ira stated that the thingy.value should not work as it has no properties. Yet the .value property is required to show a value in the debugger. (Yet, within the program code, either construct works just fine when assigning the .enabled property.) ~So Alpha must be (by default) implicitly/transparently applying the (default) .value property to make the generated the X-basic inside the eval() statement work (without .value).... And the debugger indicates that my thingy has ".value!"


    When I was referring to a "collection of objects", Alpha 5 (X-basic) was talking "class of objects" instead. (I "realized/learned" this while researching the .CHILD_ENUM() method.) And since the For Each construct doesn't support "classes of objects" (but it does support lists and collections).... These "classes" of objects must first be converted into a list, which I guess Alpha considers to be a collection.

    Now, if I can only find a real / native a5 "collection" to try this with.....
    HHhhmmmmmmm......
    Last edited by SNusa; 02-11-2012 at 10:18 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  12. #42
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: $10,000 Question ~ "The foo variable"

    Quote Originally Posted by SNusa View Post
    Ira stated that the thingy.value should not work as it has no properties.
    I said thingy had no properties, but said I had not tested it yet. As it turns out, thingy was a pointer and has a "hidden" property called .value. But just to be clear, thingy.value is a property, but there are no properties of thingy.value, but there is 1 property of pointer thingy (called value)

    Quote Originally Posted by SNusa View Post
    Yet the .value property is required to show a value in the debugger.
    The debugger doesn't necessarily work 100% identically to the real code(although for the most part it does), so one must be careful in some cases.

    The construct without .value works when you are using it in a parameter of a function (or an expression that is used for a parameter)

    Quote Originally Posted by SNusa View Post
    Technically, the form objects must be a collection, in order to create a list from in the first place. X-basic obviously doesn't allow you to access this "collection" directly though. You have to convert it
    If you are saying an apple is not an orange, yes, Alpha XBasic is not Visual Basic or anything else. It is not a good idea to assume one language must translate to another. It might, but more likely not.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  13. #43
    "Certified" Alphaholic Ted Giles's Avatar
    Real Name
    Ted Giles
    Join Date
    Aug 2000
    Location
    In the Wolds, Louth, Lincolnshire, UK
    Posts
    4,358

    Default Re: $10,000 Question ~ "The foo variable"

    This thread can only be understood with copious amounts of alcohol I've decided.
    Ted Giles
    Example Consulting - UK
    .

    http://ec12.example-software.com//
    See our site for Alpha Support, Conversion and Upgrade.

  14. #44
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Quote Originally Posted by Ted Giles View Post
    This thread can only be understood with copious amounts of alcohol I've decided.
    More laughing going on here @ my home........

    I won't quote Ira's entire reply but it clarifies quite a bit.... Especially the "debugger tip." (not working exactly like the code)

    Quote Originally Posted by csda1 View Post
    The construct without .value works when you are using it in a parameter of a function (or an expression that is used for a parameter)
    I am still (however) "chewing" on this statement (above).....

    Quote Originally Posted by csda1 View Post
    If you are saying an apple is not an orange, yes, Alpha XBasic is not Visual Basic or anything else. It is not a good idea to assume one language must translate to another. It might, but more likely not.
    My response ~ If you only knew!!!!!!
    I cut my teeth on Apple II basic, and since then I've "dobbled" with quite a few languages over the years...

    PS: When I began working with a5 (last winter) the first stuff I turned to were your CSDA tips....
    (I had figured they would provide much insight to avoid pitfalls. I saw the value back in the beginning.)


    Ironically, at this point, I'm almost more comfortable coding X-basic snippets than I am at picking the right form objects from the a5 gui to drop on a form...... (thanks largely to all the online help here!)


    ~ Being on "an oasis" I can't begin to tell you how appreciative I am for all your help.....
    (Ira, Stan, Ted, "G" and all the others who have helped me "get here from there".... Thank You!)
    Last edited by SNusa; 02-11-2012 at 10:21 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  15. #45
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default Re: $10,000 Question ~ "The foo variable"

    Quote Originally Posted by csda1 View Post
    ...But don't use a sledge hammer when a hammer will do. This is the simplest way

    Code:
    dim tblptr as p
    tblptr=table.open("tablename")
    dim fldlst as c
    fldlst=tblptr.field_name_get()
    tblptr.close()
    ui_msg_box("Fieldlist",fldlst)
    Ira, I'm shocked!biggrin.gif Isn't this simpler: (and at least 200 times faster according to my tests)
    Code:
    ui_msg_box( "Fieldlist", a5_get_fieldnames( "tablename" ) ))
    Yeah, I know, that wouldn't have been following the intent of the thread but I couldn't help myself.

  16. #46
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: $10,000 Question ~ "The foo variable"

    Hi Cal,

    Just too funny!

    Quote Originally Posted by CALocklin View Post
    Ira, I'm shocked!biggrin.gif Isn't this simpler: (and at least 200 times faster according to my tests)
    Code:
    ui_msg_box( "Fieldlist", a5_get_fieldnames( "tablename" ) ))
    As it turns out in reality, no. But 200 times faster than tbl.field_name_get()? Or did you mean the loop version? a5_get_fieldnames() is an Xbasic wrapper that will return set fields as well as table fields, so you have a function and some decision code as overhead.

    Faster is the direct function (actually a method to be 100% clear) table.external_field_name_get(). If the table referenced is already open, it runs about 10 times faster.

    Using something like table_pointer.field_name_get() is even just a bit faster than table.external_field_name_get(). Obviously you have to open the table 1st, but when you include that and a table.close(), it is still faster than table.external_field_name_get(). If the table was already open for both, it still wins by a hair.

    See comparative execute time to run code for 3 types below with and without table initially open

    Code:
    ' Init code
    dim tablename as c
    tablename="your_tablename"
    dim x as c
    
    ' Table is not open prior to running code
    x=a5_get_fieldnames(tablename)	' .00712
    
    x=table.external_field_name_get(tablename)	' .00648
    
    ' .00666 time for the next 4 lines
    dim tbl as p
    tbl=table.open(tablename)
    x=tbl.field_name_get()
    tbl.close()
    
    ' versus below if table is open already
    dim tbl as p
    tbl=table.open(tablename)
    
    x=a5_get_fieldnames(tablename)	' .00123
    
    x=table.external_field_name_get(tablename)	' .000605
    
    x=tbl.field_name_get()	' .000441
    
    tbl.close()
    So in conclusion, based upon my timings and analysis, no it is not simpler if you already have the table open, and is faster even if you have to open the table (albeit with slightly more code).

    These were all tested in V8, specific versions could vary a bit, but not likely.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  17. #47
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default Re: $10,000 Question ~ "The foo variable"

    Yeah, my 200 times faster was based on a loop that opened and closed the table each time through the loop. I assumed that was the same thing the a5_get_fieldnames() was doing.

    HOWEVER, based on your times, I tried it again this morning and the time was slightly longer to run the loop with a5_get_fieldnames() - which makes more sense. Obviously I did something different (wrong!) last night but I deleted the test script so I have no idea what it was. Even opening the table before running the a5_get_fieldnames() loop only results in running it about 10 times faster - nowhere close to the 200 times I got with whatever I did last night.

    FWIW, I thought maybe I ran the tests last night in one of the other versions. So I also tried it in v8 and v9 just now and, compared to v10, both methods take about 30-40% longer in v8 and about 300% longer in v9.

  18. #48
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    The "thingy" saga continues... I'm wondering whether I've found a bug in X-basic?

    Could someone try and explain this to me, and whether or not it may be a bug?:

    Using Alpha Sports (desktop)
    Set a few session variables in the Products form. (define them in either the "V" or OnInit of the form)
    Now, on the Items form, add a button & the following code to the button's OnPush event.

    For code below, define these session vars in Products: vc_ShareAfterClose & vc_InvoiceItem

    When you run the Items form, click on this button and see what happens.....


    Code:
    dim vp_Form as P
    dim vn_Session as N
    dim vp_SessionVars as P
    dim vc_List as C
    dim vc_String as C
    dim vc_String1 as C
    dim vc_String2 as C
    
    vp_Form= Form.view("Products")
    vn_Session= vp_Form.SessionHandle()
    vp_SessionVars= session_variables(vn_Session)
    vc_List= user_Variables_enum(vp_sessionVars)
    'vc_List= Variables_enum(vp_sessionVars) ' -BREAKS THE FOR EACH CONSTRUCT.  (issue #2)
    
    msgbox(vc_List) '-COOL, WE HAVE THE ENUMERATED LIST.....  (INCLUDING THE SESSION VARIABLES)
    
    ui_msg_box("UserSessionVars:",USER_VARIABLES_ENUM(vp_SessionVars))  ' -AND BOTH THESE LINES RETURN SAME VALUES IN LIST  (issue #2)
    ui_msg_box("AllSessionVars:",VARIABLES_ENUM(vp_SessionVars))
    
    msgbox("VARIABLES:" + chr(10) + "vc_InvoiceItem=" + vp_SessionVars.vc_InvoiceItem + chr(10) + "vc_ShareAfterClose=" 
    +  vp_SessionVars.vc_ShareAfterClose)
    
    'NOTE HOW THE SESSION VARIABLES (DEFINED ON OTHER FORM) RESOLVE PROPERLY IN MSGBOX ABOVE!
    'NOW HERE'S THE PROBLEM:  IN THIS LOOP, WHEN THINGY GETS TO THE VARIABLES,
    'eval(thingy) fails.....  'thingy.value (or just thingy) works fine though......
    '(When debugger pops up, skip and continue to the end)......
    
    for each thingy in vc_List
    	'x = eval("thingy.value") ' -doesn't work because it's not in the same frame?????
    	vc_String= vc_String + thingy.value + chr(10) ' THIS LINE OF CODE WORKS FINE
    	vc_String1= vc_String1 + thingy.value + "= " + eval(thingy) + chr(10) ' BUT EVAL(THINGY) WON'T RESOLVE....
    	vc_String2= vc_String2 + thingy + "= " + eval(thingy) + chr(10) ' Same problem here......
    next
    
    ui_msg_box("User Variables:",vc_String1 + chr(10) + vc_String2)
    vp_Form.close()
    I haven't worked on issue #2 yet.....
    As for the primary problem, all I can think of is that maybe eval() is the wrong function to be using here...
    (I can get the variable names, but not the variable values)

    ~The debugger pops up and warns that these session variables are not found, (vc_ShareAfterClose & vc_InvoiceItem )so the line of code must be "skipped."

    I'm also wondering exactly what the difference is between these two functions... (second one entirely breaks the construct)
    vc_List= user_Variables_enum(vp_sessionVars)
    vc_List= Variables_enum(vp_sessionVars)

    ... And why is A_DB_CURRENT & A_DB_CURRENT_PATH being returned here by user_Variables_enum()?
    Last edited by SNusa; 02-25-2012 at 07:41 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  19. #49
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: $10,000 Question ~ "The foo variable"

    Hi Robert,

    One session's variables are not available in another session unless you prefix the variable from the other session with the session variable pointer.

    Or if you enclose some code with a With .. End With construct, then Alpha will try that pointer as a default until it resolves the variable.
    Last edited by csda1; 02-25-2012 at 07:06 PM. Reason: Forgot with .. end with
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  20. #50
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Quote Originally Posted by csda1 View Post
    Hi Robert,

    One session's variables are not available in another session unless you prefix the variable from the other session with the session variable pointer.
    Or if you enclose some code with a With .. End With construct, then Alpha will try that pointer as a default until it resolves the variable.
    Got it.... :
    vc_String1= vc_String1 + thingy.value + "= " + eval("vp_SessionVars." + thingy.value) + chr(10)
    vc_String1= vc_String1 + thingy + "= " + eval("vp_SessionVars." + thingy) + chr(10)
    ~Both work here...

    My thingy doesn't grab the pointer to the variable, only it's name. ~It was that special case thingy pointer again throwing me off......
    I'm now wondering whether I could optionally use the "Context" parameter with =EVAL( Expression as C [, Context as C ] ) ???

    Thanks again Ira!
    Last edited by SNusa; 02-25-2012 at 08:39 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  21. #51
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: $10,000 Question ~ "The foo variable"

    Hi Robert,

    Quote Originally Posted by SNusa View Post
    I'm now wondering whether I could optionally use the "Context" parameter with =EVAL( Expression as C [, Context as C ] ) ???
    No you can't. Context is a tablename text string, and does not have any way to reference a variable space. If you use WITH .. END WITH, the eval() will use that variable space as it's default (but will search local, shared and global if not found for that variable space)
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  22. #52
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Quote Originally Posted by csda1 View Post
    Hi Robert,

    No you can't. Context is a tablename text string, and does not have any way to reference a variable space. If you use WITH .. END WITH, the eval() will use that variable space as it's default (but will search local, shared and global if not found for that variable space)
    Thanks Ira;

    The wiki actually specifies otherwise. (Thus, this is a very confusing example).......
    Context Argument (Optional): The context in which the expression should be evaluated. This can be a list of tables in a CR-LF delimited list. It can also be the name of an open form (suffixed by ".this"), which would evaluate the expression in the context of the form.
    I first saw it appear when placing a button on the Alpha Invoice browse using a genie for code creation to open the products form:
    (actual code is at bottom)

    :Form.viewqueried("Products",eval("\"product_id=\"+s_quote(product_id)",this.Name(16)+".this"),"","Normal","","",.t.)

    Which I re-wrote as: vp_FormPtr = :Form.viewqueried("Products","product_ID='"+description.value+"'","","Normal","","",.F.)
    (with a bit of help from the debugger to resolve what the parameter was actually "doing")

    ~The original a5 A/S code is still a little elusive in my mind.......
    I know that this.Name(16)+".this" refers to the browse via #16 which means the Fully qualified object name returned is :invoice:browse1....????? (which is thus designated as the "context" for this line of code.)

    ~And that in this context, the .this has a "special" different 3rd usage. (I know that "this" can refer back to an object, or when used as "object.this" typically returns a pointer to the object.) But here the ".this" suffix merely refers to the the objects name (which according to the help file should be the name of a form)... But in this case "this.name().this" actually seems to refer to the name of the browse object and returns a value of type character (as indicated by the eval() context parameter......... ~ STRANGE!!!!!!


    Alpha Sports Invoice (Browse1 button) "event" event (code originally created by wizard).....
    Code:
    function Actions_ButtonClick as v( event as C,data as C, row as N)
    	this.Set_Viewport_row(row)
    	if this.Table_Get().Mode_Get() > 0 then
    		this.Commit()
    	end if
    
    dim vp_FormPtr as P
    
    
    'ui_msg_box("EVAL:",eval(this.Name(16)+".this"))
    ui_msg_box("EVAL1:",eval("\"product_id=\"+s_quote(product_id)",this.Name(16)+".this"))
    ui_msg_box("EVAL2:",this.Name(16)+".this")
    ui_msg_box("eval3:",eval(this.Name(16)+".this"))
    
    ':Form.viewqueried("Products",eval("\"product_id=\"+s_quote(product_id)",":browse1.this"),"","Normal","","",.t.) - ERROR
    ':Form.viewqueried("Products","product_ID='"+Invoice:Tables:product.PRODUCT_ID+"'","","Normal","","",.t.) - ERROR
    'Invoice:Tables:product.PRODUCT_ID   Invoice:browse1:description.value description.value - ERROR
    ':Form.viewqueried("Products",eval("\"product_id=\"+s_quote(product_id)",this.Name(16)+".this"),"","Normal","","",.t.) ' - ORIGINAL CODE (WORKS FINE) MADE BY A/S WIZARD
    
    ':Form.viewqueried("Products",eval("\"product_id=\"+s_quote(product_id)",this.Name(16)+".this"),"","Normal","","",.t.) '- OK
    ':Form.viewqueried("Products",eval("\"product_id=\"+s_quote(product_id)",":invoice:browse1.this"),"","Normal","","",.t.) '- OK
    ':Form.viewqueried("Products","product_ID='"+Invoice:browse1:description.value+"'","","Normal","","",.t.) '- OK
    vp_FormPtr = :Form.viewqueried("Products","product_ID='"+description.value+"'","","Normal","","",.F.) '- OK (my cleaned up code)
    'ui_msg_box("desc.txt:",description.text + chr(10) + description.value)
    
    
    end function
    Last edited by SNusa; 02-27-2012 at 08:59 AM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  23. #53
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: $10,000 Question ~ "The foo variable"

    Yet another couple of oddities:

    Within a form based on a set:

    Code:
    dim vn_price as N = price.value
    dim vp_Table as P = parentform.table_get()
    dim vc_ChildTable as C = alltrim(vp_Table.child_get()) ' - Alltrim() needed to "fix" function or code below fails!
    'WITHOUT alltrim() vc_ChildTable gets the char value of PRODUCT¶ and not PRODUCT in the debugger.....
    dim vp_ChildTable as P = table.get(vc_ChildTable) ' - Woohoo!  Found a way to get pointer to child table....
    
    dim vc_FieldVal as C = ChildTable.COST ' -this works....
    dim vc_FieldVal as C = str(eval(topparent.name() + ":Tables:" + vc_ChildTable + ".COST"),10,2,",(") ' -this works to..
    'dim vc_FieldVal as C = str(eval(vc_ChildTable + ".COST"),10,2,",(") ' -but this DOES NOT WORK,
    ' (as a5 can't presumably resolve the short name here)....
    
    ui_msg_box("",vp_ChildTable.COST)
    Footnote: child_get() method returns type C
    Seems strange that you need alltrim() to remove the ¶ character which is appended to vp_Table.child_get()...
    (A debugger watch showed a value I hadn't expected which kept causing my code to fail.)
    Last edited by SNusa; 02-27-2012 at 08:55 AM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

Similar Threads

  1. ms access "views" vs. dbf "sets" question
    By er2fan in forum Application Server Version 9 - Web/Browser Applications
    Replies: 5
    Last Post: 07-03-2009, 05:47 PM
  2. "foo" - Please explain
    By enstorms in forum Alpha Five Version 9 - Desktop Applications
    Replies: 5
    Last Post: 01-21-2009, 12:48 PM
  3. form.view("fName","","","center","center")
    By reynolditpi in forum Alpha Five Version 9 - Desktop Applications
    Replies: 5
    Last Post: 07-15-2008, 12:37 AM
  4. To "zoom to record" or to "open form" using action scripting, that is the question.
    By georgefurnel in forum Alpha Five Version 9 - Desktop Applications
    Replies: 4
    Last Post: 06-18-2008, 07:32 PM
  5. "Add" and "Save" buttons don't stay on "Self" page
    By Scholin in forum Application Server Version 8
    Replies: 2
    Last Post: 02-05-2008, 08:50 AM

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
  •