Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Loop driving me loopy

Featured Replies

Hi all:

I'm working on a scheduling system with a graphical display of a schedule, using the xmChart plugin. However, I'm having a hard time getting the formatting right for the chart data. For those of you unfamiliar with xmChart, if I've got three items on the agenda in a five day week, the data might look like this:

(0 0; //Monday, no meetings

12 14; // Tuesday, meeting from noon to 2pm

0 0; // Wednesday, no meetings

10 12 13 15; // Thursday, a meeting from 10-12, another from 1-3pm

0 0;) // Friday, no meetings.

Now, I've gotten to the point where I have my found set & am able to pull the data for the chartable items. What's NOT going right is being able to fill in the "0 0;" for empty days. Something is so wrong with my loop that I'm not even going to bother entering it here - I think my logic is faulty at the core.

The data I'm using includes having the day of the week represented as a number (for sorting purposes) as well as the numerical hours as shown above. I need to step through the sorted data and, for items that appear on a particular day, fit the numerical hours between the semi-colons; for days that have no meetings, I've got to have the "0 0;"...Can anyone show me the logic for this?

Thanks

-Stanley

Hey Stanley,

I've done several different types of charts with xmChart, so I may be able to help. What kind of records are you sorting? Are they days or meetings?

  • Author

Ender:

Thanks for chipping in.

They're classes, actually. The data in the records (for the chart) is all numeric - nStartTime, nEndTime, nDayOfWeek. I've got it sorting, and pulling the right data - that's fine. But I'm not catching empty days.

Also, I'm working with a Gantt Chart (like the last sample on that page in the xmGallery file.)

Right now I'm using a very long list of If statements in a loop which runs through all the class records (once they've been sorted by day & start time), and I've got a global I am incrementing to track where I am. Each If checks for the day of the week, thus:

If [Classes::nDayOfWeek =1]

copy & paste hour data

End If

If [Classes::nDayOfWeek (isnot) 1 & Classes::gTracker = 1]

Insert Text [Classses::tChartText; "0 0;"

Set Field [Classes::gTracker; 2]

End If

This is reiterated for all 7 days of the week, within the loop. The idea being to track what day I'm on, and to use the gTracker to identify where to put in the "0 0;" lines. But it doesn't work. The first day (in my test) is empty, and it works then, but the gTracker stops at "2"...

-Stanley

How about something like this:

Set Field [ gTracker , 1 ] //Holds the last day of week

Set Field [ gChartText, "" ] //Holds the chart text as it's built

Go to Record/Request/Page [ First ]

Loop

If [ nDayOfWeek <> gTracker ]

If [ nDayOfWeek = gTracker+1 ]

Set Field [ gChartText, ChartText & "0 0;" ]

Else

Set Field [ gTracker , nDayOfWeek ]

Set Field [ gChartText , gChartText & ";" & <Hour Data> ]

End If

Else

Set Field [ gChartText , gChartText & ";" & <Hour Data> ]

End If

Go to Record/Request/Page [ Next ]

Exit Loop If [ gTracker >= 8 or Status(CurrentRecord) = Status(CurrentFoundCount)]

End Loop

Loop //In case there are no events late in the week, this puts empties in graph for those dates

Exit Loop If [ gTracker >= 8 ]

Set Field [ gChartText, ChartText & "0 0;" ]

Set Field [ gTracker , gTracker + 1 ]

End Loop

I'm not sure if it works, but that's probably how I would start.

  • Author

Ender:

That didn't work, but you set me on the right path, especially regarding adding the last items to the list. I also discovered that I was skipping blank days in the middle, but I've (finally) got the thing figured out.

Thanks

-Stanley

Using the script debugger in Developer is especially helpful in debugging scripts like this (if you can afford it.)

  • Author

Ender:

In the end, it was nothing the script debugger would have seen - all bad syntax in calculations, really (and bad calculations, too)...

-Stanley

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.