Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to get the Max Integer Value in the Array?

Enthusiast ,
Apr 20, 2021 Apr 20, 2021

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
Mohammad Hasanin
TOPICS
Scripting
651
Translate
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

Community Expert , Apr 20, 2021 Apr 20, 2021

Oh, you want:

var maxNum = Number.MAX_VALUE;

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

Translate
Community Expert ,
Apr 20, 2021 Apr 20, 2021

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();

 

Translate
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

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
Mohammad Hasanin
Translate
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
Community Expert ,
Apr 20, 2021 Apr 20, 2021

Oh, you want:

var maxNum = Number.MAX_VALUE;

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

Translate
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

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
Mohammad Hasanin
Translate
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
Community Expert ,
Apr 20, 2021 Apr 20, 2021

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

-Manan

Translate
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
LATEST

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

Regards

M.Hasanain

Best
Mohammad Hasanin
Translate
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