1. Tracy Lamb
  2. PowerBuilder
  3. Tuesday, 3 August 2021 15:17 PM UTC

Hi friends,

I created a user event in my dw, and wrote a routine.  Today, I've been trying to add a conditional loop, but can't save the changes due to error C0031: Syntax Error.  The offending lines are the first IF statement and associated END IF .

 

//Loop through the attachments and print each one...
if lower(ls_forms[ li_y ]) = "attachments"
li_attachments = lds_form.RowCount()
   if li_attachments = 0 then
      MessageBox("Print Attachments", "No attachments to print.")
   else
      istr_parms = f_get_doc_directory(istr_parms)
      ls_directory = istr_parms.string_arg[1]
      SetNull(ls_null)
      for li_this_row = 1 to li_attachments
         ls_filename = this.GetItemString(li_this_row, "filename")
         ls_filename = ls_directory + '\Workorder\' + string(il_workorder) + '\' + ls_filename
         // Print
         shellexecute(handle(this), "print", ls_filename, ls_null, ls_null, 0)
      next
   end if
end if

When I comment out this section, everything saves and run fine. I'm sure it's something obvious, but I'm not seeing it. Any suggestions?

TIA,

Tracy

Accepted Answer
Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 3 August 2021 15:26 PM UTC
  2. PowerBuilder
  3. # Permalink

if lower(ls_forms[ li_y ]) = "attachments" THEN

 

Best,

.m

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 19 June 2023 17:56 PM UTC
  2. PowerBuilder
  3. # 1

Valid IF statement (no end if needed if code on same line):

if rb_hombre.checked = true then descuento = 0.10

Valid IF statement (using end if):

if rb_hombre.checked = true then
    descuento = 0.10
end if

INvalid IF statement (missing end if):

if rb_hombre.checked = true then
    descuento = 0.10
Comment
There are no comments made yet.
Olaya Vega Velasco Accepted Answer Pending Moderation
  1. Monday, 19 June 2023 11:26 AM UTC
  2. PowerBuilder
  3. # 2

I have a problem with this code

//Variables
double bici, pesas, pasarela, descuento

// Asignación de valores de acuerdo a la selección:
if rb_hombre.checked = true then
descuento = 0.10

if cbx_bicicletas.checked = true then
bici = 100
if cbx_pesas.checked = true then
pesas = 300
if cbx_pasarelas.checked = true then
pasarela = 250

elseif rb_mujer.checked = true then
descuento = 0.15

if cbx_bicicletas.checked = true then
bici = 100
if cbx_pesas.checked = true then
pesas = 300
if cbx_pasarelas.checked = true then
pasarela = 250

else
messagebox("aviso", "seleccione el tipo de descuento")
end if

Error: C0031: Syntax error

 

Can someone help me? Thanks!

Comment
  1. Chris Pollach @Appeon
  2. Monday, 19 June 2023 12:40 PM UTC
I agree. Also, you need to be very specific as to what line of code is failing.

BTW: the IDE Debugger is your friend. ;-)
  1. Helpful
  1. Andreas Mykonios
  2. Monday, 19 June 2023 12:56 PM UTC
Hi Chris.

I believe the issue is related to one or more missing end if. This example seems to be very bad coded.

Andreas.
  1. Helpful 1
  1. Miguel Leeuwe
  2. Monday, 19 June 2023 17:37 PM UTC
Yes, many "end if" missing. Then repeatedly assigning same values to already assigned values.

This code is BAD or ... maybe it hasn't been pasted correctly in the post.

regards
  1. Helpful
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Tuesday, 3 August 2021 15:34 PM UTC
  2. PowerBuilder
  3. # 3

OMG! Thank you so much! I have no idea how I missed that... 

~~~Tracy

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.