ObjectScript

Syndicate content 29 

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
0 1
0

comments

136

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 1
488

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 4
0

comments

708

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

0 3
0

comments

228

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
0 1
316

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
515

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
179

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 1
0

answers

475

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 1
256

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 3
217

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 2
0

comments

168

views

0

rating

If I were trying to access an index of a global variable, what time complexity would this operation have? My understanding of languages like Java/C++ is that arrays are stored as blocks of memory so that x[15] would have a lookup time complexity of O(1) because it just goes to (address of the array + 15) and retrieves the value stored there.

How does this work in Cache where the index of a variable isn't necessarily an integer value? If I were to have a variable like the following:

x("Adam") = "Red"

x("George") = "Blue"

x("Bryan") = "Green"

etc...

Would the lookup operation scale with the size of the array such that the variable is iterated through until the given index meets the current index, yielding a O(n) lookup? Or is this done a different way?

Last answer 6 February 2017 Last comment 7 February 2017
0 2
228

views

0

rating

I am in the planning stages of making things more uniform in our routines and I would like to know what the easiest way would be to include an .inc at the beginning of each .mac routine. Has anyone written something that would open all routines and place something into the first row while leaving the rest of the routine unchanged? Thanks for any guidance you all may provide.
Last answer 3 February 2017 Last comment 30 January 2017
0 0
162

views

0

rating

Points to remember before you start: 

  1. It is not possible in a COS (Caché Object Script) job/process context to have multiple Named Pipes. It is a one Named Pipe per job/process limited line of communication. 

  1. Named Pipes, in Caché, like most pipes on most operating systems are Unidirectional. That means you open them for either Read or Write, but not both. 

0 2
0

comments

334

views

+ 2

rating

Hello guys,

I've got this piece of code which runs the method "WebMethod", that belongs to %SOAP.WebBase.cls.

It grabs the outcome from an internal webservice we have and after that, it writes into a file.

The thing is, when I browse the file contents, I realize that in the place where a special character should be, I see a question mark.

By querying the same webservice from a special soap tool called "SoapSonar" (I've been using this for years), the outcome shows up this special character (shows it properly).

So I wonder... is there kind of encoding parameter I could use within the "WebMethod", so it'd return the correct output?

--

Last answer 31 January 2017 Last comment 2 February 2017
0 2
1983

views

+ 1

rating

Have you ever thought what could be a reason why some development environment (database, language) would eventually become popular? What part of this popularity could be explain as language quality? What by new and idioms approaches introduced by early language adopters? What is due to healthy ecosystem collaboration? What is due to some marketing genius

Last comment 17 January 2017
0 1
648

views

+ 9

rating

So I know it's been a while, and I hate to let my adoring fans down... just not enough to actually start writing again.  But the wait is over and I'm back!  Now bask in my beautiful ginger words!

For this series, I am going to look at some common problems we see in the WRC and discuss some common solutions.  Of course, even if you find a solution here, you are always welcome to call in and expression you gratitude, or just hear my voice!

This week's common problem: "My query returns no data."

Now, supposedly you've checked that your query SHOULD return data.  That is, if you do a "SELECT * FROM MyTable" and don't get back any data, I don't expect that your more complicated query with JOINs, a WHERE clause, and a GROUP BY will either.  So, if you've determined that the data lives in your table what else could be going wrong?

 

1) You're in the wrong namespace.

Last comment 16 January 2017
0 2
265

views

+ 7

rating