Jump to content

This topic is 7452 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi, new here but I've been using fm for 3 months now. I need help. Request: Each time someone adds a comment to a comment field, it inserts their new comment at the beginning and also puts current date in blue first, like:

9-4-04: new sentence here. Previous comment text.

Also, that it only keeps 5 comments then drops the oldest each time a new is added. They don't want a portal, just one field. Here is what I've done so far, but I'm stuck:

Script attached to Comment field with Set Selection [ Start:0, End:0 ]

I'm not concerned about it not activating when tabbed to ... the layout is such that most are radio, checkbox and popup and they would need to click into field anyway. I have Custom Function for Blue. I added an auto entry calc (with replace) of:

Blue(

GetAsText(

Substitute(Get(CurrentDate); "/"; "-"))

& ": ") & Comment

It works roughly except for 3 things:

1) The next time a comment is added, the entire new comment comes out blue. I think my calc is pretty right because the first time it works right - only date turns blue. It breaks after that though.

2) I can't get the year in the date right. It comes out 9-4-2004.

3) I have no idea how to isolate and remove the oldest (6th) comment. It may be more than one sentence. Do I need to insert a strange character that I can then identify or can I isolate that last 'entry' another way, like possibly the date?

I think I can fix the 'all blue' problem if, when I Set Selection, I can also change the default color to black (using TextColorAdd (?) but I can't figure how to do that either.

Please advise. grin.gif

Posted

Hi Bekah, and welcome to the Forums,

Please update your profile to reflect your platform, operating system, and the version of FileMaker you are using. The link is just below your Name, in the Box to the Left, and is in blue "profile".

Using GetasText in your post, does tell us you are using v7, having the information complete will be helpful when needed.

Thanks,

Lee

p. s. I don't v7, so I can't help you with problem here.

Posted

Here is one way, using a separate field for the new comment, and having a special comment character marking where they start. I added a custom function called "TodaysDate" that computes the date string in the format you wanted.

If you weren't going to allow comments to be more than one line, you could just use LeftValues( Comment Log, 4 ) to truncate the previous comments down to four.

Posted

Amazing. This place is amazing and your solution is amazing! I prefer the way you lined them up. I will try to talk them into this idea. But I figure I'd better be prepared in case they want to stay with the 'one ongoing sentence' idea. So I want to have both methods available.

Can you look at my attached file? Is that okay to ask? I removed the return from the calculation. My file shows the little remaining snag in pulling this off. Is there any way (if they decide to keep it runon sentence, yuk) to keep that date from splitting on me when it hits an end of line? If not, it'll just be another argument for your better idea; but I like to be ready for anything. You are a genious and I appreciate your help. smile.gif

Posted

Here's a variant that holds the date together better.

I changed "TodaysDate" custom function to use a non-breaking hyphen rather than a normal one. That requires the use of the font "Lucia Grande" on the Mac, otherwise you'll see boxes.

I also changed the auto-enter calculation to use non-breaking spaces around the date.

These two things seem to convince FileMaker that the date is one big word, and make it start a new line for it if there isn't enough room for it all.

Posted

Wow, you are on track, on the ball and on target! I just get the squares though. I don't have Lucia Grande to try (although I'm XP, I thought I'd give it a shot). I tried Lucia Bright, Lucia Console, Times New Roman, Arial, Currier Verdana and Tahoma. I'm so close I can taste it. I tend to want to say heck with it ... your way was better anyway.

But a big part of me wants to get it. So if your busy I understand. What you've already given me is great and I might spend some time going through various fonts because the principle is terribly worth understanding and using for many things. smile.gif

Posted

I don't know how Windows handles the special characters, the Mac has a way to see everything that's available, and what fonts support it. One alternative would be to keep the dates with "/" as the separator, as I don't think those will word-break either.

The only US font that shows the non-breaking hyphen on my Mac is Lucia Grande:

NonbreakingHyphen.pdf

Posted

Ok, I have three alternatives. Your original, the modified runon and one which inserts a paragraph between entries but removes a pargraph if its in the same Comment. It gets too segmented and hard to read otherwise. In this way, they can just choose which one best fits their needs. And since staff will want to edit their comments (these are critical text entries which need to remain visible and modifyable in this field), I attached a script and stacked the two fields (only on the first box in this example) so they can edit, add or cancel (which would stop putting the date in the field if they decide they don't want to enter something) but accidently click into it.

If you or anyone has additional ideas, I would love to hear it ... I probly could have a better script idea (or input handling) or something but this is all I could think of. Any other suggestions?

Now you watch ... they'll want something altogether different! But this has been fun learning and I know I'll be using it for different things. grin.gif

testcomment_1.zip

  • Newbies
Posted

Bekah,

Another option is to use an extra global repeating field and to have the comment field use a calculation. That is, you will have 3 text fields: New Comment; Comment and g_comment (with g_comment being a repeating field with 5 slots). Comment is the field that displays the full comment and is auto-entry with the following calculation:

TextColor ( Get ( CurrentDate ) ; RGB ( 0 ; 0 ; 255 ) ) & "

Posted

Hi Derek, not sure what this will look like and I am trying it to see. smile.gif

I have everything in place (including using text[5] instead of global, but when I go to write the script using Set Field - I don't see where I can select the field gGlobal and specify [5] to start with?? I can see that I can specify gGlobal[4] in the calc box - but how do I get the 5 selected. It only brings up a specify field dialog. Silly huh. blush.gif Oh! Found it! Never mind! Sorry! Never saw that little tiny box on Specify Field before!!?? grin.gif

I'll let you know ... it'll be nice to have another alternative although I don't know what it'll look like. But I like surprises. Thank you!

Posted

They are going to have so many options they will be totally confused as I'm beginning to feel ... but I haven't enjoyed something so much in quite a long time. Okay, I'm going to include your alternate; however, I must have something wrong. It doesn't keep the original date which we need. And I forgot to use the CF for the date but I think I can incorporate that also.

And I have a fear they will try to add to the 'log' field instead of entering in the New Comment field - if they can do it wrong, they will. But maybe I'll turn off entry into it - they can modify their existing entry (without my script). That is all they would/should modify anyway, I think.

Can you see if you can tell what I'm missing? I admit I struggle greatly with simple things ...

I'm a bit worn out. No wonder you guys get paid big bucks for this stuff. laugh.gif

testcomment_1.zip

Posted

Oh Shadow! I didn't see you attached a file! I just changed the boxes to /!! I'll take a look and try to see if I blew it or not! It seems to work but I'll check to make sure. You all are so very helpful ...

Update: I don't know where to find this. I have hunted in every fm menu item. Maybe it's just late but / works great anyway, right? crazy.gif

Posted

Sorry, I should have explained more, that was a dialog from Mac OSX that shows the fonts the special non-breaking hyphen was available in - if you could find a corresponding Windows thing, it could tell you if you have a chance of seeing the hyphen with any font you have.

Good luck!

  • Newbies
Posted

Bekah,

To have each line have the date stay attached, just remove the

TextColor ( Get ( CurrentDate ) ; RGB ( 0 ; 0 ; 255 ) ) & "

Posted

That worked Derek. And I changed the script calc to reflect my Custom Function (Blue) and (TodaysDateList). So the 6th line becomes:

Set Field [ Blue ( TodaysDateList) & ": " & Substitute(testcomment::NewComment;

testcomment_1.zip

Posted

Bekah,

Glad to be of assistance. I think the problem with the SetSelection method is that its simulating you clicked at the start of field and started typing - if you do that, the new text that is inserted is also blue, as its picking up the style from the beginning of the text.

Posted

"...new text that is inserted is also blue, as its picking up the style from the beginning of the text."

That was my sense of it at the time. I even tried inserting black text first (Insert Text and also Insert Calculated Result with CF Black("~~"), jumping ahead of it and then deleting the black text. It just seemed there should be a way to force the issue but I'm not good at this stuff. grin.gif

Posted

This is something that I want to utilise for my database. I'm a BDM and need to list action taken with a particular contact.

The date in a different colour with comments like this is just what I want!! But, I'm a tad confused about how to do it. I like the version (on the example) where you click a button and can add an entry but don't understand the script - what is a gComment? I don't understand global fields at all so I hope it's not that....

Can you shed some light for me please.

Posted

Ooops blush.gif Well Derek should explain since it's his but I want to apologize for the error ... gComment started as a global and we changed it to a regular field. I copy examples - put g before global fields so I know. It is just a regular field (with 5 repetitions) to hold each comment and as a new comment is added, they all move down one and the last drops off. It won't need to be displayed anywhere; it just holds the comments. We use Comment4Log because it displays right; squeezes the lines into right format.

If you want them spaced equally like this, use gComment instead and get rid of Comment4Log. Really, just place that gcomment field in my demo on the form. Set field format to display all 5 repetitions then add comments. I think how it works will become clear. grin.gif

Posted

Thanks. I've got it working. It didn't really become crystal clear, although the water is less muddy, so I've no real idea how it works, but that's fine - as long as it works!

The one thing I cannot manage to do is change the date format to DD/MM/YYYY when I Get[current date]. I can do this when I have a date field and I've done it for my CalSnap connection (that's a good date picker....) but not for this. Any suggestions?

Posted

I don't know calcs very well so sorry. The Shadow or Derek could certainly help you. But ... what is your system date set as? Oh, never mind ... blush.gif

The Shadow used a Custom Function date and Derek's was a regular date, I think, so it should work if your system settings are right. Never mind ... forget I jumped in. I don't know. Sorry. crazy.gif

Posted

Thanks, I'll have another go at figuring it out....

Another problem I've now found is:

If I edit the comment log, it automatically updates the log with today's date whtether or not there is a new comment. Any idea how I can stop this happening?

Posted

I don't allow editing on my log so I don't know sorry.

Derek, The Shadow, Forum people ... I don't know this stuff. I posted a question and I don't know how to help him. Am I supposed to? Can someone help this nice person please?

  • 2 weeks later...
Posted

In filemaker community, it has become pretty much a standard naming convention to use g as a prefix of a variable name, which you are going to make global.

so gName, gComment and gDate are all globals. Just because you name them that doesn't mean they are global though, you must specify this in the define fields dialog. The important part, as you probably know, is to set the storage setting - check the box in the Group box called "Global Settings". Now it will be global.

if repeating is set to 1 - this is the way I usually use it, then this means that whatever value you put in the global variable no matter which record you are on in that table, if you look at the value of that global variable, it will be the same

so, if i have a global variable called gName and I used SetField(gName, "Fred Flintstone") in a script and I have twenty customer records in that table. If I look at any of them and print out the gName (you can place it in a layout as a field by the way), then it will always be "Fred Flintstone" - until you change it.

this allows you to set a variable, which can contain information which you want to be available no matter what record you are in. It's very handy for exchanging data between different databases.

Hope that starts to help,

sincerely,

J__

Posted

Nt one bit. Sorry, but thanks for trying.

...and this is probably not the info you were looking for re: logs.

I am very much a beginner and although have figured out a lot through trial and error and from help through the forum, I cannot fathom relationships or global fields.

Anyone else able to help?

Posted

  Quote
If I edit the comment log, it automatically updates the log with today's date whtether or not there is a new comment. Any idea how I can stop this happening?

You have contridicted yourself from what you indicated above, in that you used the process in which you 'clicked a button' to update. This thread has become muddied and unclear. Depending upon WHAT you've implemented, it sounds like it might be something simple such as an unclicked 'Do not Evaluate if All Fields Are Empty' checkbox which appears in your calculation dialog. If this is unclicked, it will cause reevaluation every time the field is entered.

Otherwise, since I'm still unclear on whether you even have the date issue fixed, I suggest you post a new clean question explaining exactly what you have and specifically what problem is remaining on it. smile.gif

This topic is 7452 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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