Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Script Misbehaving in V9

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Script Misbehaving in V9

    I've got the following script attached to a button on a form that searches for invoices that are ready to be created. A single customer may have 30 products that are flagged to be invoiced and they should just appear in the result dialog box once. The user then may click on that customer and create one invoice for all the products that match the search criteria.

    This script worked fine in V8. In V9 it displays the customer name once for each product that is ready to be invoiced.

    It would be really difficult to create a test app to be able to show how this functions so I am going to include the code along with a couple of screen shots hoping someone can see what I am overlooking.

    In the attached picture (v9) Smith & Johnson should only be displayed once in the browse).

    Thanks!

    Code:
    'Date Created: 20-Oct-2005 05:21:01 PM
    'Last Updated: 23-Oct-2005 10:22:23 PM
    'Created By  : 
    'Updated By  : 
    
    'Prompt for password and store result in a variable called 'pw'.
    'DIM SHARED pw AS C
    
    'Enter_pswd:
    'pw = ui_get_password("Password Required","Enter Password:","********","********")
    'IF pw = ""
    '	END'
    'END IF
    'IF pw <> "123"
    '	msg = "You have entered an incorrect password." +crlf(2)+ "Please try again or click 'Cancel' to quit."
    '	ui_msg_box( "Incorrect Password", msg, 16 )
    '	GOTO Enter_pswd
    'END IF
    
    '------------------------------------------------------------------------------------
    'Get list of all Billto Names to with products that match the filter criteria.
    '------------------------------------------------------------------------------------
    'Get list of IDs from products table.
    idlist = table.external_record_content_get( "products", "Billto_Id", "Billto_Id", "Completed  .and. .not. Done .and. unique_key_value()" )
    IF idlist = ""
    	ui_msg_box( "NOTHING TO BE INVOICED", "No products' to be invoiced.", 16 )
    	END'
    END IF
    'Based on IDList, get names.
    inv_names = table.external_record_content_get("billto","Name + space(50) + ' -- ' + Billto_id","Name","Billto_Id$\"" + idlist + "\"")
    
    'Show them in xdialog so user can select them.
    'chcs = inv_names
    dlg_text = <<%dlg%
    {ysize=.3}{units=F}{font=font_face,fsize,n}{sp};
    {font=font_face,fsize,b}{'Select client(s) to be billed:}{font=font_face,fsize,n};
    {justify=center}<Select All>  <Clear All>;
    {justify=left}
    [%m%.50,15chcs^#inv_names];
    {line=1,0};
    <*15OK> <15Cancel>
    %dlg%
    
    dlg_text = xd_set_fonts( dlg_text, "A", 9 )
    
    DIM dlg_result as C
    dlg_result = ui_dlg_box( "CLIENT NAMES", dlg_text, <<%code%
    IF a_dlg_button = "Clear All"
    	chcs = ""
    	a_dlg_button = ""
    ELSEIF a_dlg_button = "Select All"
    	chcs = inv_names
    	a_dlg_button = ""
    END IF
    IF a_dlg_button = "OK"
    	IF chcs = ""
    		ui_msg_box( "SELECTION REQUIRED", "Please select names to be invoiced or press 'Cancel' to quit.", 48 )
    		a_dlg_button = ""
    	END IF
    END IF
    %code%)
    
    IF dlg_result <> "OK"
    	END'
    END IF
    
    'Get last invoice number. (Compare both tables JIC)
    tpi = table.open( "Invoices" )
    query.filter = ""
    query.order = "val(padl(invoice_no,8,\"0\"))"
    query.options = ""
    tpi.query_create()
    tpi.fetch_last()
    inv_inum = alltrim( tpi.Invoice_no )
    tpm = table.open( "Menu" )
    tpm.fetch_goto(1)	'JIC
    Inum = tpm.invnum 'Current invoice number - numeric
    IF val(inv_inum) <> Inum
    	msg = "The last invoice number in the Invoice table, " + inv_inum + ", does not match "
    	msg = msg + "the last invoice number shown in the Menu table: " + ltrim(str(Inum)) + crlf(2)
    	msg = msg + "If you continue, the number " + Inum + " will be used as the last number." + crlf(2)
    	msg = msg + "CONTINUE?"
    	mresp = ui_msg_box( "WARNING", msg, 32+ui_yes_no )
    	IF mresp = ui_no_selected
    		tpi.close()
    		tpm.close()
    		END'
    	END IF
    END IF
    
    tps = table.open("products")
    tps.index_primary_put("Billto_Id")
    
    TotInv = 0
    TotInv_amt = 0
    i = 0
    
    'Build invoices for each Billto_ID selected.
    lcnt = line_count( chcs )
    FOR qx = 1 to lcnt
    	this_line = word( chcs, qx, crlf() )
    	this_name = alltrim(word( this_line, 1, " -- " ))
    	this_id = alltrim(word( this_line, 2, " -- " ))
    	Inum = Inum + 1 'Get NEXT inv num
    	Inumc = padl(ltrim(str(Inum)),8,"0") 'Convert to character padded left with "0"
    	TotFee = 0 'Total Fee for CURRENT Invoice record
    	tps.fetch_find( this_id )
    	WHILE tps.Billto_id = this_id .and. .not. tps.fetch_eof()
    		IF tps.Completed .and. .not. tps.Done
    			'********* Insert invoice no into COMPLETED products record ************
    			TotFee = TotFee + tps.Fee
    			tps.change_begin()
    			tps.invoice_no = Inumc
    			tps.done = .T.
    			tps.change_end( .T. )
    		END IF
    		tps.fetch_next()
    	END WHILE
    
    	'************* Create  New Invoice
    	'Fill in NEW invoice fields
    	tpi.enter_begin()
    	tpi.billto_id = this_id
    	tpi.invoice_no = inumc
    	tpi.invoice_date = date()
    	tpi.status = "Open"
    	tpi.invoiced = .F. 'T = invoice has been sent to the customer
    	tpi.total_fee = TotFee
    	tpi.total_paid = 0
    	tpi.Billto_name = this_name
    	tpi.enter_end( .T. )
    	totinv = totinv + 1
    	TotInv_amt = TotInv_amt + TotFee
    
    	'Update the invoice number in Menu after each invoice in case the routine crashes for some reason.
    	tpm.change_begin()
    	tpm.invnum = inum
    	tpm.change_end( .t. )
    
    	statusbar.percent( qx, lcnt )	'no easy "nrecs" when selecting multiple bill-to IDs.
    NEXT
    
    Code = ui_ok + ui_information_symbol
    msg = "Created " + ltrim(str( totinv, 6 )) + " NEW invoices for a total of $" + ltrim(str(TotInv_amt,10,2,",")) + "."
    response = ui_msg_box( "Invoicing Complete", msg, Code )
    IF response = ui_no_selected
    	END'
    END IF
    
    tpm.close()
    tpi.close()
    tps.close()
    
    'Close current form or browse window.
    IF is_object( parentform.this )	'Just to make dev work easier.
    	parentform.close()
    END IF
    
    END'
    
    FUNCTION XD_set_fonts as C ( dlg_text as C, font_face="Arial" as C, fsize=9 as N )
    	DIM GLOBAL g_std_font_face as C
    	DIM GLOBAL g_std_font_size as N
    	IF g_std_font_face <> ""
    		font_face = g_std_font_face
    	END IF
    	IF g_std_font_size <> 0
    		fsize = g_std_font_size
    	END IF
    	SELECT 
    		CASE font_face = "" .or. font_face = "A"
    			font_face = "Arial"
    		CASE font_face = "MSS" .or. font_face = "A"
    			font_face = "MS Sans Serif"
    		CASE font_face = "V" .or. font_face = "A"
    			font_face = "Verdana"
    		CASE font_face = "T" .or. font_face = "A"
    			font_face = "Tahoma"
    		CASE font_face = "TR" .or. font_face = "A"
    			font_face = "Times Roman"
    		CASE font_face = "C" .or. font_face = "A"
    			font_face = "Courier"
    	END SELECT
    	
    	dlg_text = stritran( dlg_text, "font_face", font_face )
    	FOR qx = 10 to 1 step -1
    		eval( "fsize" + ltrim( str( qx ) ) ) = eval( "ltrim(str(fsize+" + ltrim( str( qx ) ) + "))" )
    		dlg_text = eval( "stritran(dlg_text, \"fsize" + ltrim( str( qx ) ) + "\", fsize" + ltrim( str( qx ) ) + ")" )
    	NEXT
    	XD_set_fonts = stritran( dlg_text, "fsize", ltrim( str( fsize ) ) )
    	
    END FUNCTION

    Appreciate any advice,
    Tim

    #2
    Re: Script Misbehaving in V9

    What happens if you execute the same query/filter directly on the relevant table(s)? Although I'm sure I saw another post where text in an Xdialog was repeated inexplicably...

    Comment


      #3
      Re: Script Misbehaving in V9

      Forgot to mention - this behaved normally in the trial version of V9 (1369-3159)

      Comment


        #4
        Re: Script Misbehaving in V9

        I don't see how it is possible that your code could ever have worked in any version of a5, because your code that does the query to populate the list in the dialog does not specify unique values. Your code is:

        Code:
        inv_names = table.external_record_content_get("billto","Name + space(50) + ' -- ' + Billto_id","Name","Billto_Id$\"" + idlist + "\"")
        Does the 'billto' table have duplictate names in it? I presume it does.

        Your filter expression does not specify that you want unique records only.

        If you want unique values you must use the unique_key_value() function in your filter rexpression.

        For example, the following can be tested in Alphasports, Interactive window:


        Code:
        ?table.external_record_content_get("customer","bill_city","bill_city","left(bill_city,1) < 'd' .and. unique_key_value()")
        If you remove the '.and. uniuqe_key_value()' from the filter, you will see duplicate city names.

        Comment


          #5
          Re: Script Misbehaving in V9

          Tim, without sample data our hands are pretty well tied.

          Using AlphaSports I was able to determine that the unique_key_value() function seems to be working ok.

          Using build 1391_3165 I see this in the interactive window, when building a list of invoice numbers that contain at least one item record with an extension value greater than $20.00. Since many invoice have multiple records with item extensions greater than $20, I would expect to see duplicate invoice numbers in the list if the function was broken. I don't. This suggests something else is going on at your location.

          Code:
          my_list = table.external_record_content_get("invoice_items","invoice_number","Invoice_number","Extension > 20 .and. unique_key_value()")
          ?my_list
          = 000001
          000002
          000003
          000004
          000005
          000006
          000007
          000008
          000009
          000010
          000011
          000013
          000014
          000015
          000016
          000017
          000018
          000019
          000020
          000021
          000023
          000024
          000025
          000026
          000027
          000028
          000029
          000030

          Comment

          Working...
          X