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

Production Schedule into Array?

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

    Production Schedule into Array?

    The 2 tables below are shown after the fact. The first is the table where machines are assigned each day to an employee per shift. The 2nd is the production table where each employee's production is entered for each machine per shift. What I would like to do is get a list that looks like the 2nd table from the 1st table so I can create a lookup to the employee assigned to a particular machine when entering the production data so the user is limited to the employee schedule which was created first. Make sense? How do I go about getting such a list?

    sched_map.jpg
    Robin

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

    #2
    Re: Production Schedule into Array?

    Any ideas on how to do this 'reverse crosstab'? I just need a push since I am clueless!
    Robin

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

    Comment


      #3
      Re: Production Schedule into Array?

      I don't see where the data is obtained for the third record in prodsplt. I see the first two and the fourth but not the machno 05 for file 1366.
      There can be only one.

      Comment


        #4
        Re: Production Schedule into Array?

        I don't see where the data is obtained for the third record in prodsplt. I see the first two and the fourth but not the machno 05 for file 1366. How many mach# fields are there?

        Looks like you just need to process m_sched. Loop through, filtering first for date if necessary. Create a record in prodsplt for each mach# field with a value. Sort prodsplt on machno, shift, and fileno.
        There can be only one.

        Comment


          #5
          Re: Production Schedule into Array?

          Good catch Stan - File 1366 should have Mach# 05 in his schedule. I am working backwards from data already entered into the prodsplt table to create the m_sched table.

          My current scenario is to get a list from the m_sched table for a particular date for every machine assigned to an employee and write that to a temp table that can then provide the employee fileno when the prodsplit data is entered for each machine. IOW when the data is entered for Mach # 05, only 1366 should be the choice for the fileno. When I get this list working, I will add the shift # too so the relevant shift and machno only has one fileno to select.

          I have tried to loop thru the m_sched table incrementing a var to map tbl.mach+"x" six times without much luck so far...
          Robin

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

          Comment


            #6
            Re: Production Schedule into Array?

            Assigning to mach#

            for qx = 1 to 6
            eval("mach"+alltrim(str(qx))) = 'something
            next

            or reading it

            for qx = 1 to 6
            'something = eval("mach"+alltrim(str(qx)))
            next

            Something like this, I think. Knocked together in wordpad, don't have Alpha available at the moment.


            Code:
            tbl_dest = table.open("prdsplt")
            tbl = table.open("m_sched")
            tbl.fetch_first()
            while .not. tbl.fetch_eof()
            for qx = 1 to 6
            if alltrim(eval("tbl.mach"+alltrim(str(qx)))) > ""
            tbl_dest.enter_begin()
            tbl_dest.prodate = tbl.schedate
            tbl_dest.machno = eval("tbl.mach"+alltrim(str(qx)))
            tbl_dest.shift = tbl.shift
            tbl_dest.fileno = tbl.file_no
            tbl_dest.enter_end()
            end if
            next qx
            tbl.fetch_next()
            end while
            tbl.close()
            tbl_dest.close()
            Last edited by Stan Mathews; 11-12-2015, 11:35 PM.
            There can be only one.

            Comment


              #7
              Re: Production Schedule into Array?

              Thanks Stan,
              I am not too sure which way to go with this - table or list, but this got me the list I wanted:

              Code:
              dim tbl as p
              dim idx as p
              dim vdate as d
              dim i as n = 1
              dim recs as n
              dim list as c = ""
              dim x as c
              dim vfile as c
              dim vmach as c
              dim vshift as c
              dim fltr as c
              tbl = table.open("m_sched")
              vdate = {11/03/2015}
              fltr = "schedate = "+s_quote(var->vdate)
              idx = tbl.query_create("NT",fltr,"file_no")
              recs = idx.records_get()
              if recs < 1 then
                     goto CLOSEIT
              end if
              tbl.fetch_first()
              on error goto CLOSEIT
              while .not. tbl.fetch_eof()
              	i=1	
              	for i = 1 to 6	
              		x = alltrim(str(i))
              		vfile = tbl.file_no
              		vshift = tbl.shift
              		vmach = EVAL("tbl.mach"+x)
              		if vmach <> "" then
              			list = list+crlf()+cdate(vdate)+"|"+vmach+"|"+vshift+"|"+vfile+"|"
              		end if		
              	next i
              	tbl.fetch_next()
              end while
              CLOSEIT:
              tbl.close()
              list = sortsubstr(list,crlf())
              msgbox("List",list)
              I will try it as a function with a parameter for the date that I can run when I create a new production template - in which case the table idea is probably better...
              Last edited by MoGrace; 11-13-2015, 12:59 AM. Reason: cx to "next i"
              Robin

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

              Comment


                #8
                Re: Production Schedule into Array?

                If you're going to use an array then your list is probably the preferable result. I just don't use arrays that often.

                Isn't eval() a useful tool though?
                There can be only one.

                Comment


                  #9
                  Re: Production Schedule into Array?

                  I haven't tried it yet, but a field rule with a filtered table lookup on this temp table should work fine. The table will be zapped and rebuilt before going to the prodsplt table where the lookup will be used. And yes EVAL() is very handy once I learned how to use it!

                  Edit: The field rule lookup works great, however my script was skipping records - fixed it in the function below.

                  Code:
                  FUNCTION Sched_LU AS C (vdate as d = {})
                  'DESCRIPTION: Populates a temp table with m_sched to get fileno for machno & shift in production template
                  	dim tbl as p
                  	dim tmp as p
                  	dim idx as p
                  	dim i as n = 1
                  	dim recs as n
                  	dim list as c = ""
                  	dim x as c
                  	dim vfile as c
                  	dim vmach as c
                  	dim vshift as c
                  	dim fltr as c
                  	zap_it("tmpsched")
                  	xbasic_wait_for_idle()
                  	tbl = table.open("m_sched")
                  	tmp = table.open("tmpsched")
                  	if vdate = {} then
                  		vdate = date()
                  	end if
                  	fltr = "schedate = "+s_quote(var->vdate)
                  	idx = tbl.query_create("NT",fltr,"file_no")
                  	recs = idx.records_get()
                  	if recs < 1 then
                  		goto CLOSEIT	
                  	end if
                  	tbl.fetch_first()
                  	on error goto CLOSEIT
                  	while .not. tbl.fetch_eof()
                  		i=1	
                  		for i = 1 to 6	
                  			x = alltrim(str(i))
                  			vfile = tbl.file_no
                  			vshift = tbl.shift
                  			vmach = EVAL("tbl.mach"+x)
                  			if vmach <> "" then
                  				tmp.enter_begin()
                  					tmp.schedate = vdate
                  					tmp.machno = vmach
                  					tmp.shift = vshift
                  					tmp.file_no = vfile
                  				tmp.enter_end(.t.)			
                  			end if			
                  		next i
                  		tbl.fetch_next()
                  	end while
                  	CLOSEIT:
                  	tbl.close()
                  	tmp.close()
                  	response = msgbox("View Records","Would you like to see the table?",292)
                  	if response = 7 then
                  		goto ENDIT
                  	else	
                  		A5_OPEN_DEFAULT_BROWSE("tmpsched.dbf",".t.","machno+shift") 
                  	end if
                  	
                  	ENDIT: 
                  	Sched_LU=dtoc(vdate)
                  END FUNCTION
                  Last edited by MoGrace; 11-13-2015, 01:04 AM.
                  Robin

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

                  Comment

                  Working...
                  X