ObjectScript

Syndicate content 31 

On the back of my recent post on writing bug-less code I wanted to raise a few suggestions (to ISC) that would help prevent certain types of bugs at compile time. I've probably missed a few, but these are the main ones in my mind. Please contribute more suggestions.

Btw, these also serve as potential gotchas for new COS developers.

I except that introducing these types of changes can cause legacy code problems. Particularly where developers do some interesting overloading of method arguments. Therefore I would see these as an option that would need to be enabled and that it won't prevent compilation (it would warn not error).

As an alternative I could see these being implemented as a Lint tool. This is something I (and perhaps the community) would be willing to do if we had an open source AST tree as a starting block (if anyone is aware of one in existence for COS)

Last comment 18 April 2017
+ 4   0 1
689

views

+ 4

rating

Cache Studio almost always crashes when I click rows in Call Stack view during debugging. Then Cache has to be restarted because last edited file remains locked.

Looks like I'm the only one who uses the debugger. Or is there a magic spell to make stack view working?

Cache 2016.1.1

Last answer 12 April 2017 Last comment 17 April 2017
0   0 0
314

views

0

rating

I have classes A and B, B derived from A, A has method Abc.

From INT of class B I see that compiler copies implementation of Abc to class B, so that Abc exists both in A and B.

As result, when B invokes Abs, B.Abs() is executed instead of A.Abs(). In result debuger is not able to step into Abs and breakpoints in A.Abs never hit.

Why this happens and how can I avoid this?

Update:

OK, now I know the reason: compiler makes the copy if Abc has this line:

cn=##Expression($$$quote(%classname))

hmmmm... compiler needs name of method's class so it "moves" the method to child class. Well, perhaps there is a good reason for that but for the moment the solution looks strange

Last answer 12 April 2017 Last comment 12 April 2017
0   0 4
210

views

0

rating

With help from others here I had developed some code to take a Base64 PDF within a OBX.5 and save it locally to the file structure on the server.

I had to make a change to the code to return me a String so I can pass the Path back into Ensemble to use it in the message. When I made this change I am getting " ERROR #5034: Invalid status code structure ("/ensemble/data/transfer/AncillaryPDF/TMSAUDIO/Apr-11-1/980512729TMSAUDIO1046784936436537800.pdf")"

Here is the code...

Last answer 12 April 2017
0   0 0
0

comments

329

views

0

rating

There is a large file that needs to be processed, with over 500 000 rows. Each row needs to be verified for various data and then all the results collated and reported into a single report.  What is the most efficient way to do this? I tried calling the processing function with Job , where each function jobbed off would report results to a different node of a common global. But the jobbed functions are not updating their respective rows even though I am passing the global name and root node. What is the most efficient way to process this large file? Any Cache/Ensemble ideas are appreciated.

Last answer 12 April 2017
0   0 2
0

comments

501

views

0

rating

Hello, we have a few hundreds of triggers to port from Oracle to Cachè for a migration project, and many of them have to change (for example, normalize a value, null it, etc) the value which is being inserted.

The documentation says "You cannot set {fieldname*N} in trigger code." , so we're unlucky.

Is there a good workaround for this ?

SqlComputeOnChange doesn't seem the best way, but I'm not totally sure: for example normalization and validation could have a better place somewhere else than a trigger.

Last answer 2 April 2017
+ 1   0 1
0

comments

149

views

+ 1

rating

What are the differences between a process private global and a percent variable?  Basically I have some code running in an Ensemble operation that processes requests, and it needs access to pieces of data that are scattered throughout XData blocks in various classes.  Rather than opening the XData object and deserializing the XML on each request, I opted to cache this data in a percent variable, something like:

set %MyVar(sub1,sub2) = myValue

Which works out nicely: it's accessible from any code invoked by the operation, it persists for as long as the operation is running, and I can clear it out by restarting the operation, if I need to change the XData, for example.  However that got me thinking: I could get all that same behavior from a process private global.  So how are PPGs and %-vars different?  Why choose one over the other?

Last answer 2 April 2017 Last comment 14 March 2017
0   0 1
520

views

0

rating

Hello,

We are working on creating a metadata file to accompany PDF documents produced by one of our third party systems for ingestion into our DMS.  One of the pieces of data that the metadata file must contain is the number of pages of the PDF document.

In Cache ObjectScript does anybody know if there is currently a way of counting the number of pages within a file (specifically a PDF) without invoking a non-Caché ObjectScript program/function from within Caché ObjectScript?

If we have to invoke a non-Caché ObjectScript program/function from within Caché ObjectScript then we will but we wanted to ensure that there wasn't a function within cache that can perform this (we can't seem to find one so suspect that currently there is not)?

Thanks

John

Last answer 29 March 2017
0   0 4
0

comments

764

views

0

rating

Hi everyone,

I've created an Identicon Generator inspired on Fabio Gonçalves Captcha Validator.

This sample can be used to create Identicons for users of app for example, it can be useful to use in Zen Mojo applications, generating an identifier image based on name of the user by example, but it can be used in others kind of applications too(Zen, CSP etc)

 

Examples:

First one:

Will generate this:

 

And this:

Will generate this

+ 4   0 3
0

comments

252

views

+ 4

rating

Inspired by the article "Declarative development in Caché" that's still trending  on the dev com. The OP explored a functional style of iterating over a collection. A comment today suggested "Caché would need syntax support for anonymous functions".

With Macros you can kind of get anonymous like syntax using dot notation.

This is not production code, but it does work. First the macros..

Last comment 29 March 2017
+ 2   0 1
331

views

+ 2

rating

I have a number of Business Process and due to the complexity these were created as "custom code" instead of BPL.

These processes currently invoke other components using SendRequestSync. For a couple of reasons I would like to be able to change these to use SendRequestAsync

Last answer 22 March 2017 Last comment 23 March 2017
0   0 0
552

views

0

rating

Let's say I have two classes: A and B. They share no common parent except %SystemBase. But these classes have some properties with the same name (type may be the same or not):

Class A {

Property data As C;

Property data2;

}
Class B {

Property data As D;

Property data3;

}

I need to automatically convert  object of class A into object of class B. I'm planing to write a class generator that generates a separate class that converts A to B.  It would work like this:

1. Query %Dictionary to get list of properties:

  • With the same names
  • With both properties being of datatype or object type

2. Iterate over result and generate convert method

Last answer 23 March 2017 Last comment 23 March 2017
0   0 0
190

views

0

rating

Hi, 
I've organized my repository using TortoiseSVN. I was careful to use only svn commands while creating my file structure. Now all Subversion commands are working at the command line but not from within my IDE (Cache Studio). Basically I'm trying to write a plug-in for my IDE to use Subversion from within the Studio. Trying to integrate Subversion into my IDE, something like Subclipse, but for Cache Studio.  The error occurred after reorganizing my code into directories. For example at the command-line, svn info and svn status and all other commands work perfectly.  All Subversion commands work at the command prompt!

Last comment 10 March 2017
0   0 1
0

answers

520

views

0

rating

I am trying to write some code that takes in a string and does a serverside transformation of it to find embedded URLs and replace it with clickable links.   I found the following regex for Javascript which is rated highly on StackOverflow;

    replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
    replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank">$1</a>');

And I tried to do the following in Caché ObjectScript but it's not working

Last answer 7 March 2017 Last comment 7 March 2017
0   0 1
270

views

0

rating

Hi!

Consider I have a class Package.Data with Property UniqueStringValue as %String.

I introduced the Index for this property:

 Index ValueIndex on UniqueStringValue [Unique];

It works well.  But if I try to check if there is an object with the certain value in code like this:

if ##class(Package.Data).ValueIndexExists(value)  

this expression fails, if value="value", even if there is an instance with instance.UniqueStingValue="Value"

How can I set the index to prevent saving case sensitive values in this class?

Last answer 27 February 2017 Last comment 28 February 2017
0   0 3
227

views

0

rating

While I can see the benefits that $ZSTORAGE could have if used properly, I have not seen it used in the environments I have worked in. I was wondering if there are any developers that promote its usage.

If used properly, I would imagine it could be highly effective in maximizing free memory since some processes will never go over X amount, while others may very well need much more.

Last answer 23 February 2017
0   0 2
0

comments

174

views

0

rating