Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to get the Max Integer Value in the Array?

Enthusiast ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Hi Experts

I need the Maximum Integer to include in my script so Instead of 1000

for (var i = 0; i < 1000; i++)

it will be :

for (var i = 0; i < MaxInteger; i++)

 I Searched the InDesign DOM but not find anythig!, Please Help

Thanks in Advance

Regards

M.Hasanain

Best
M.Hasanain
TOPICS
Scripting

Views

149

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
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Apr 20, 2021 Apr 20, 2021
Oh, you want: var maxNum = Number.MAX_VALUE; Not sure why, though...it is very large.  

Likes

Translate

Translate
Adobe Community Professional ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

A bit unclear. Assuming your Array is all integers, then you need to sort it then get the last entry. Sort() will not give you max by default; you need to roll your own. From this stack exchange

 

var numArray = [104, 140000, 99];
numArray.sort(function(a, b) {
  return a - b;
});
var maxInteger = numArray.pop();

 

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
community guidelines
Enthusiast ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Thank you Mr.brianp311, what i mean that instead of using limited number like 1000 or 2000, etc i want the array to loop to maximum allowed integer number in indesign javascript! maybe it will be million? as i assuming!, do you think there are a method for that?

Regards

M.Hasanain

Best
M.Hasanain

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
community guidelines
Adobe Community Professional ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Oh, you want:

var maxNum = Number.MAX_VALUE;

Not sure why, though...it is very large.  

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
community guidelines
Enthusiast ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Thank you very much Mr.brianp311

I need the maximum value because i make a script that will help you to start numbering in different way, so i dont want to limit the user with maximum number, thank you a lot

Regards

M.Hasanain

Best
M.Hasanain

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
community guidelines
Adobe Community Professional ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

I am not sure what you are trying to achieve, if it's about iterating your array then array.length should work.

-Manan

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
community guidelines
Enthusiast ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

LATEST

Thank you a lot for your Help Mr.Manan Joshi, i will try this also

Regards

M.Hasanain

Best
M.Hasanain

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
community guidelines