Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need help to rewrite script

Posted on 2016-10-22
3
94 Views
1 Endorsement
Last Modified: 2016-10-22
I have this script:
sub pddinstock()
      if useStockManagement AND showinstock=TRUE then if cint(rs("pStockByOpts"))=0 then print "<div class=""prodinstock detailinstock""><strong>" & xxInStoc & ":</strong> " & vrmax(0,rs("pInStock")) & "</div>"
end sub

I need to change it so that " & vrmax(0,rs("pInStock")) & " returns an output like "Few items left."  instead of the " & vrmax(0,rs("pInStock")) & " value when the value of " & vrmax(0,rs("pInStock")) & " is less than 5 and when the value of " & vrmax(0,rs("pInStock")) & " is more than 5 it should say "In stock."

I have tried to rewrite the script, but as I'm doing it in Notepad I have to test it after each modification and I have still not figured it out. Now I've been at it for a few hours. Anyone know how to rewrite it?

Many thanks in advance.

Best regards,
Evert
1
Comment
Question by:EvertJor
3 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 41855210
try

sub pddinstock()
      inStockText = "a few items left"
      if CInt( vrmax(0,rs("pInStock")) ) > 5 then inStockText = "in stock"

      if useStockManagement AND showinstock=TRUE then
          if cint(rs("pStockByOpts"))=0 then
              print "<div class=""prodinstock detailinstock""><strong>" & xxInStoc & ":</strong> " & inStockText & "</div>"
          end if
     end if
end sub
0
 
LVL 18

Expert Comment

by:xtermie
ID: 41855223
This expert suggested creating a Gigs project.
Could you explain your variables?

It looks smt like
sub pddinstock()
       if useStockManagement AND showinstock=TRUE then
            if cint(rs("pStockByOpts"))=0 then
                 'does this means there is stock available
                  if xxInStock < 5 then msgbox "your message"  else msgbox "your second message"
            end if
       end if
       
 end sub
0
 

Author Closing Comment

by:EvertJor
ID: 41855254
Excellent solution.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question