Highlighted

Use function details outside function

Explorer ,
Jul 07, 2020

Copy link to clipboard

Copied

Hi,

I am using this function/code to get marker text. I want to use the output of this function in another function which I am unable to do so.

 

Is there a way to store/use the text2 outside this function?   

 

 

#target framemaker

var doc, marker, nextMarker, regex, text2;

regex = /^newlink Filename\:.*/;

doc = app.ActiveDoc;

function getMarker(doc, text2){
marker = doc.FirstMarkerInDoc;
while (marker.ObjectValid () === 1) {

    nextMarker = marker.NextMarkerInDoc;

    if (marker.MarkerTypeId.Name === "Hypertext") {
    
        if (regex.test (marker.MarkerText) === true) {
    
			text2 = marker.MarkerText;
	
        }
    }
	
    marker = nextMarker;
	
}
}

alert (text2);

 

Views

42

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Use function details outside function

Explorer ,
Jul 07, 2020

Copy link to clipboard

Copied

Hi,

I am using this function/code to get marker text. I want to use the output of this function in another function which I am unable to do so.

 

Is there a way to store/use the text2 outside this function?   

 

 

#target framemaker

var doc, marker, nextMarker, regex, text2;

regex = /^newlink Filename\:.*/;

doc = app.ActiveDoc;

function getMarker(doc, text2){
marker = doc.FirstMarkerInDoc;
while (marker.ObjectValid () === 1) {

    nextMarker = marker.NextMarkerInDoc;

    if (marker.MarkerTypeId.Name === "Hypertext") {
    
        if (regex.test (marker.MarkerText) === true) {
    
			text2 = marker.MarkerText;
	
        }
    }
	
    marker = nextMarker;
	
}
}

alert (text2);

 

Views

43

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 07, 2020 0
Enthusiast ,
Jul 07, 2020

Copy link to clipboard

Copied

It's Javascript basic:

 

 

call function like this:

var Text = getMarker(doc, pgf, text2)
function getMarker(doc, pgf, text2){
.
.
.
.
return text2
}

 

We all like to help you with special problems, but your questions indicate that you have not yet mastered the basics.

I would suggest that you get into the basics of programming first.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 07, 2020 1
sam.m1 LATEST
Explorer ,
Jul 08, 2020

Copy link to clipboard

Copied

Thank you Klaus, I will keep this in mind.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 08, 2020 0